2009-07-30
I bumped into an issue while trying to get the open source ASP.NET MVC project NerdDinner running on my laptop. The Create action in the DinnersController just wouldn’t work. This was due to Latitude and Longitude values being set with a different decimal separator than my server expected. It got "0.0" instead of "0,0" which the Double.parse function didn’t understand. A client-side JavaScript wrote these values into hidden fields, so it was a bit difficult for me to understand at first. I wrote a custom model binder to solve this for all fields of type double at once.
As I’m still learning ASP.NET MVC, my solution may not be the optimal one.
Read the rest of this entry »
Posted in ASP.NET MVC | Comments Off
2009-03-20
Apparently Internet Explorer 8 has a more aggressive caching mechanism than any other browser I’ve ever met. To fix it I’ve added the following to almost every dynamic page on my server.
<%
// prevent caching (asp classic jscript)
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
%>
<%
' prevent caching (asp classic vbscript) '
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>
<?php
// prevent caching (php)
header('Cache-Control: no-cache');
header('Pragma: no-cache');
header('Expires: ' . gmdate(DATE_RFC1123, time()-1));
?>
// prevent caching (C#)
//Response.AddHeader("Cache-Control", "no-cache");
//Response.AddHeader("Pragma", "no-cache");
//Response.Expires = -1;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.MinValue);
More information here: How to prevent caching in Internet Explorer
Posted in asp | Comments Off
2009-03-16
After seeing the Silverlight Chess sample I immediately started work on a flash version. It needs a lot of optimizing, not a single variable type was set, so it’s not a very fair fight. Anyway … flash is about 10x faster than the ie7 js engine on my machine. But still a lot slower than silverlight.
Read the rest of this entry »
Posted in Flash, Silverlight | 4 Comments »
2009-03-02
Generating Excel files in ASP Classic is not as easy as I thought. I hope someone finds use in this little piece of code that shows a way to export data to csv and to xls.
Read the rest of this entry »
Posted in asp | 2 Comments »
2009-02-24
In my previous blogpost I mentioned a way to retrieve the entire tree from a hierarchy stored with adjacency tables. Now I’ve got a way to retrieve a random employee in an organisation.
I use ORDER BY NEWID() to randomize the order and TOP 1 to get only one result.
WITH Bosses (id, boss_id, name, depth, hierarchy)
AS (
SELECT id
, boss_id
, name
, 0
, name
FROM People
WHERE boss_id IS NULL
UNION ALL
SELECT People.id
, People.boss_id
, People.name
, Bosses.depth + 1
, CONVERT(VARCHAR(50), Bosses.hierarchy + ' > ' + People.name)
FROM People
, Bosses
WHERE People.boss_id = Bosses.id
)
SELECT TOP 1 *
FROM Bosses
WHERE depth >= 2
ORDER BY NEWID();
Posted in sql | 1 Comment »
2009-02-24
I’m well aware that adjacency tables aren’t the newest way of storing hierarchies in a database. Personally I prefer to use nested sets. But on this one project I had to work with a legacy database. It took me quite a while to find out how to retrieve an entire tree in one requests. This is obviously needed to speed up queries on large amounts of data.
This query is here to help me remember how to do it.
DROP TABLE People;
CREATE TABLE People (
id INT NOT NULL PRIMARY KEY IDENTITY
, boss_id INT
, name VARCHAR(50)
);
SET IDENTITY_INSERT People ON
INSERT INTO People (id, boss_id, name)
SELECT 1, NULL, 'Bert'
UNION ALL SELECT 2, 1, 'Sylvie'
UNION ALL SELECT 3, 1, 'Sylvia'
UNION ALL SELECT 4, 2, 'Davy'
UNION ALL SELECT 5, 2, 'Xavier'
UNION ALL SELECT 6, 3, 'Kristof'
UNION ALL SELECT 7, 3, 'Piet';
WITH Bosses (id, boss_id, name, depth, hierarchy)
AS (
SELECT id
, boss_id
, name
, 0
, name
FROM People
WHERE boss_id IS NULL
UNION ALL
SELECT People.id
, People.boss_id
, People.name
, Bosses.depth + 1
, CONVERT(VARCHAR(50), Bosses.hierarchy + ' > ' + People.name)
FROM People
, Bosses
WHERE People.boss_id = Bosses.id
)
SELECT *
FROM Bosses
ORDER BY Bosses.hierarchy;
| id | boss_id | name | depth | hierarchy |
| 1 | NULL | Bert | 0 | Bert |
| 3 | 1 | Sylvia | 1 | Bert > Sylvia |
| 6 | 3 | Kristof | 2 | Bert > Sylvia > Kristof |
| 7 | 3 | Piet | 2 | Bert > Sylvia > Piet |
| 2 | 1 | Sylvie | 1 | Bert > Sylvie |
| 4 | 2 | Davy | 2 | Bert > Sylvie > Davy |
| 5 | 2 | Xavier | 2 | Bert > Sylvie > Xavier |
Posted in sql | Comments Off
2008-08-29
I had some issues today to change the background color of a button in Flex. The up-skin was set for the Button selector which meant setting the fill-colors property for the Button.special selector had no effect. Setting the up-skin to null was the only solution. This was easy to do in code with setStyle, but I wanted to do it in css. Writing null wasn’t quite enough. Apearently you need to use ClassReference(null). Hope this helps someone out.
Button {
up-skin: Embed(source='img/example.png');
}
Button.special{
up-skin: ClassReference(null);
fill-alphas: 1.0, 1.0;
fill-colors: #00FF00, #00FF00;
}
Posted in Flex, css | 1 Comment »
2008-05-23
A hands-on workshop about Silverlight 2.0.
The many MacBooks that are available are probably set up for the Air session this afternoon. Our speaker informs us "We wont be using those", quickly followed by "Silverlight is a cross platform …".
Blend has loads of panels and properties. Nesting controls is possible. You can have a video inside a button.
Changes in Blend are detected in Visual studio. It helps to do a rebuild in Blend to make shure Visual studio isn’t working on an old version. Design view isn’t fully supported there yet. Double clicking on a button doesn’t get you a onClick handler yet.
Silverlight uses layout managers like Flex. Buttons have a content property which enables design and programming to be done separately. You can create some kind of color palette of Brush Resources in Blend which translates to SolidColorBrush elements in XAML. Visual studio has intellisence for XAML which makes it easier to type in there than in Blend. Fullscreen is supported but must be initiated by the user. Controls have a background and a border while other elements have a fill and a stroke. Blend has some glitches when setting properties on multiple controls. Switching to XAML code is the normal reaction to that. Not shure how designers will react to that. Hope these things are fixed when it goes out of beta.
The presentation was quite good, but I’m not sure weather I’m going to dump flash for this.
Posted in Uncategorized | Comments Off
2008-04-23
A long overdue overview of the on Air event in Brussels.
Read the rest of this entry »
Posted in AIR | Comments Off
2008-04-18
Plist files are more and more ubiquitous. Apple uses them for its configuration files and we use them to describe exercise content. They aren’t very pleasant to read for humans, but that doesn’t mean computers dislike reading them. So I wrote a little javascript to parse a plist file to an object. Hope you like it.
Read the rest of this entry »
Posted in Uncategorized | Comments Off