November 2006
21 articles published in November 2006
-
Refactor the code before you write it
Have you ever heard the saying “If you don’t know where to look, don’t look at all”? Think about this saying and coding. If a piece of code somewhere in the system is causing an error, don’t split the whole thing apart...
-
An HttpModule that moves ViewState to the bottom
There are two reasons why it is desirable to do so. The first is for letting search engines see more of your content rather than the big portion of ViewState many sites have. The other is perceived rendering time, which...
-
Brute force protect your website
On a website with the ability for users to logon, it is a good idea to have some sort of password policy. The most widely used contains minimum requirements for the length of the password and that the individual...
-
Combine accessors in C#
Today I had to add some functionality to an already existing class library. In there were a internal virtual method that I thought were supposed to be protected virtual. To no big surprise, I couldn’t compile after...
-
Using the W3C HTML Validator API
The W3C has introduced an API for their HTML Validator. It is not a SOAP web service, but it does return XML that can be parsed, so now you have the ability to incorporate validation to any web application, Windows...
-
Add multiple classes to HTML elements
I recently realized that you can add more than one class to a single HTML element. This opens up to even more structured stylesheets and more code reuse. It’s a standard and has cross-browser support. You simply just...
-
Is ASP.NET too difficult?
There is no doubt in my mind, that ASP.NET is the most powerful and versatile platform for web applications at the moment. By leveraging the .NET Framework you can do absolutely anything in no time, but is that power...
-
Pull a prank on your co-workers
Office pranks are among the funniest and we’ve probably all done some of our own over the years. This time, my boss and I came up with a good one. Write an add-in for Windows Live Messenger that auto replies to all...
-
Remove unused objects from the session
The Session in ASP.NET is a very simple way of storing user specific data for the duration of a single user session. I’ve many times added data to the Session that had an even shorter lifespan. That could be as a data...
-
Tip for localized websites and the html tag
For a website that supports multiple languages, it is important to tell the client what the selected language is. This is done in the <html> tag in the lang or xml:lang attribute and could look something like this for an...
-
Replacement for invisible columns in the GridView
For security reasons Microsoft doesn’t allow invisible columns in a GridView to be posted back like it does in the old DataGrid. That makes it impossible to store the ID of the row in an invisible column and then use it...
-
Event handling with anonymous methods in C# 2.0
One of the nicest things about the new anonymous methods is how simple event handling has become. Here is an example of how we used to handle events. It demonstrates how to add an event handler to the btnSave’s Click...
-
A realtime currency exchange class in C#
Soon, I’m facing a new project where the need for up-to-date currency exchanges is crucial. This is not the first time I’ve done this, but I wanted to make a reusable, self-maintainable class so I don’t have to do it...
-
Looking at The World as an outsider
Lately, I’ve felt a bit alone in The World of what’s new, cool and wonderful. If you’ve been following the Web 2.0 blogs lately, you know what I’m talking about. I feel like everybody is talking a language I don’t...
-
Permanent redirection in ASP.NET
The easiest way to make a redirection in ASP.NET is using Response.Redirect(url). What it actually does is, that it creates a response with the “302 (Object Moved)” status code and the target destination. It tells the...
-
Simple method to avoid comment spam
We probably all know about the annoying captcha images that a lot of blogs uses for separating humans from machines (spam robots). I use a captcha image to avoid comment spam on this blog because I get a lot, but I...
-
Toggle visibility of non-server controls from code-behind
Since ASP.NET 1.0 you had the ability to toggle the visibility of any HTML tag with the runat=”server” attribute. The only prerequisite is to add the runat=”server” and ID attributes, but that is not always possible or...
-
Boost performance using the CompilationMode attribute
ASP.NET 2.0 introduced the CompilationMode attribute to let the developers decide how to compile individual pages, user controls and master pages. You can set the value to these three values: Always Auto Never This is...
-
Add social bookmarks to dasBlog
As you can see at the bottom of each blog post, I’ve added social bookmark links. Because I use dasBlog version 1.8 it was very difficult to do, mainly because there is no macro to print out the title in clear text of...
-
Submit disabled controls in ASP.NET 2.0
I recently built a JavaScript function in HeadLight that filled a textbox from JavaScript and then disabled the textbox to prevent the user to alter its contents. When the form was submitted, it didn’t submit the...
-
Control the number of alternate rows in the GridView
The GridView control (as well as the DataGrid) has a way of defining the style of every other row of the grid. My favorite way of doing it, is to set a class on the row and then by stylesheet set the background like so...