Saturday, July 26, 2008

ASP.NET Server Controls vs HTML Controls

When I first started off with development in ASP.NET, I would always use plain ol' HTML tags instead of the ASP.NET server-side tags, hoping to save a bit on performance. However, as I picked up more concepts from ASP.NET, I gradually moved away from the HTML tags and now rely on them primarily for positioning of elements with DIVs. Now, all of you readers who are PHP fans and have never ventured into the ASP.NET camp would probably ask, "What do you have to gain from using server-side tags?".

The first thing that comes to mind is "globalization". You can pick up values from the resource file and whenever a change in language is needed, you can simply switch the strings in the resource file. The feature also makes building multi-lingual sites a breeze. To avoid the issue of re-compiling, there are satellite assemblies, which I hope to cover some other time.

Next comes the ability to re-base references. If you were to host your web application at a top-level directory served by the web server all the time and simply host additional websites on other ports or with different host names, all goes well, but what do you do when you want to host the application on a virtual directory? Back in the old days, that took a bit of re-writing of references but that isn't something for you to sweat about with ASP.NET. You can specify the "~" character for the base location of the application and the references would be automagically created for you on the server-side tags.

Finally comes the ability to let the IDE and the ASP.NET framework take care of rendering the HTML while you simply specify the properties on the control. Although there are times you would want to deal with 'raw' HTML directly, you wouldn't need to do this for the most part so why bother? With ASP.NET themes and skins, you'll also have an easy way to change the appearance of controls without having to visit each page.

Are you still using HTML tags within your ASP.NET application?

PS: I initially titled this post "Making things tougher for the ASP.NET server or easier for the developers" but then decided against it as the current title makes it easier to search via a search engine.

No comments: