Tuesday, 17 October 2006

Checking your web app against different browser resolutions

    I have found three basic methods:
  1. Use an online type of viewer.
    You select the resolution, type in the URL of your site, then sit back and relax.
      I see a lot of problems for this method:
    • you don't want everybody to know you are working on a site

    • you don't want the site to be open to the public while you work on it

    • you need an internet connection


  2. Use an external program.
    BrowserSizer is as good as any. It's free and easy to use. You select the resolution and it resizes your IE window accordingly.
    The only problem I see is that you need the program. You install it, it messes with your browser settings, etc.

  3. Use a javascript script in the IE addressbar:
    javascript:db=document.body;bst=db.style.zoom=1;rd=prompt("Width:",800);
    db.style.zoom=db.offsetWidth/rd;void('')

    Unfortunately, the zoom messes up quite a few things, including fixed table headers or custom javascript controls. However, I do believe it is the best solution for most situations.

ASP.NET DefaultButton on LinkButton or ImageButton and Mozilla Firefox

You may experience unexpected results when you open a Web page that is in an ASP.NET 2.0-based application in Mozilla Firefox and the DefaultButton property is assigned to a LinkButton control or an ImageButton control

Just a reminder of a bug I am likely to encounter. The obvious solution is to use ControlAdapters or inheritance to create LinkButtons and ImageButtons that are rendered as buttons.

FxCop - automatic check of NET code.

I've accidentally stumbled upon FxCop, a Microsoft free tool that analyses the generated NET code (.exe or .dll) for bad design practices.
While many of the errors and warnings I got were related to casing, a lot of them were not and they had come with links, extended information and solutions. The rules that FxCop has help you to make members static if none of the instantiated object's properties or members are used in it, use case insensitive String.Compare instead of comparing two ToLower strings, or StringBuilder in loops, use NET 2.0 constructs instead of 1.1 ones, etc.
I find it at least interesting and I intend to use it in my future software projects.

Monday, 16 October 2006

Missing on spam!

I've recently changed my email address, added spam filters both on the server and on the client and moved all known addresses into a special folder, leaving any unknown source (thus mostly spam) emails alone in the inbox folder. This resulted in me not receiving spam email for at least a week. Now I kind of miss it. I mean, I feel something is wrong, like some essential part of my life is gone. How weird is that?
And apparently, I am not alone. 231 pages in Google have "I miss spam" in them.

Thursday, 12 October 2006

Virtualize! Good bye, cruel real world!

ASP.NET 2.0 has this nice feature called Virtual Path Providers. What it
actually does is enable you to get your site files from anywhere using an
override of the VirtualPathProvider class.

Virtualizing Access to Content: Serving Your Web Site from a ZIP File
This is a very nice article where a Microsoft guy shows how to run a
complete ASP.NET site from a ZIP arhive. Just two lines of code in
global.asax , a standard web config file and a ZIP arhive.

This opens up a lot of possibilities, like reading the ASPX or CS files from
a class that creates them dynamically, or reading the files from multiple
sources at once. Yummy!

Tuesday, 10 October 2006

Nullable types in C# 2.0

I vaguely remember reading of nullable types in the C# 2.0 "what's new" documentation, but somehow it slipped by me. Now I've stumbled over this useful new feature and I can explain it for a bit.
Here is the Microsoft explanation.

Basically you can declare any value type as nullable by using the syntax <type>?.
Example: int? x=null;
There is even a nice operator ?? that acts like the SQL isnull function.
Example: int y=x ?? 0;
The two above examples are the short for the following:
System.Nullable x=null;
int y=x==null?0:x.Value; int y=x.HasValue?x.Value:0; OR int y=x.GetValueOrDefault(0)

    The Nullable type has some nice methods:
  • GetValueOrDefault([value]) - gets the default value or the specified value when the nullable type is null

  • HasValue() - something like is not null



There is no IsNull method to the Nullable type. Also, x=null makes x==null true, as opposed to, let's say, the SqlInt32 type.

Sunday, 8 October 2006

Thomas Covenant, by Stephen Donaldson

I've just finished The Runes of the Earth, the first in the last series of the Thomas Covenant saga. I must say that the style and content changed significantly from the first books, therefore I felt the need to review the whole saga as I see it now.
I liked that in each book new ideas were introduced, they weren't just reprints of the same story. The moral basically stays the same, but everything else, sometimes even the lead character, changes.
From the second series, a new model of writing was used, thus all the books in one series make out a story rather than one book per story. I didn't like that, especially now, when I have to wait for the next books to be published in order to see what is going on. What I also minded was the need of the characters to shed tears over all kind of stuff. I think the author overdid the misty eyes scenes. A lot of the creatures and the culture from the first series was completely obliterated in the second, but it seems to be making a come back now.
The good thing about it, though, is that the writing gets better with each book. In hindsight, the first book seems amateurish compared with the rest. No more singing, more story, less descriptions. It is interesting that the last series of the Chronicles of Thomas Covenant the Unbeliever was published 20 years from the end of the second. Donaldson justified this as taking time to become a better writer before ending the story.
Let's see how it goes.