While I have been writing a lot about ASP.NET AJAX and other stuff, I also wanted to keep adding my little nuggets on ASP.NET 2.0 which is one of the favorite platforms for Web Development. While working with ASP.NET 2.0 and Visual Studio 2005, you may not know certain new things which are a part of it and usually go unnoticed. At least I missed them and after a year, completing a big application realized that it would have been great if I had used these features.
So, here it is, 10 things you might not know about ASP.NET 2.0
No need to press "Ctrl + Shift + B" (Build) for everything
When working with ASP.NET 2.0 and Visual Studio 2005, you dont need to press Ctrl + Shift + B (in other words build) to check every change you make to the source / design. Both the ASPX Page and Code behind files are compiled dynamically when you run the page and if there is a change, the source / design is recompiled accordingly so you dont have to rebuild the solution. In fact the only instance where you want to rebuild the solution is when you add an external DLL reference / modify and add an external DLL again, where I have found some cases when the change is not reflected.
This would save a lot of time particularly in big projects where you have lot of source files and building all of them for each and every change would consume lot of time.
Data Source doesnt always need to be SQL DataSource
When working with Data Sources most of us would have seen the SQL Data Source examples and always said "Ah, this is good for Demo but what about enterprise applications where I cannot have the SQL Query or Stored Procedure mentioned in the Data Source definition in the ASPX Page" Object Data Source accepts your business layer methods as inputs and very well acts as a bridge between your business layer.
Web.Config is more friendly to IIS
Web.Config is one of the favourite things and the toughest nuts to crack in terms of editing them. While most of us might have seen Web.Config edited using the Website Administration Tool (if it sounds like alien to you or have never tried out, go to "Website - ASP.NET Configuration" in Visual Studio 2005), little is known that you can edit the Web.Config settings using IIS - yes Internet Information Services.
When you install ASP.NET 2.0 (gets installed when you install Visual Studio 2005 as in most of the cases), you get the "ASP.NET" Tab for virtual directory properties and that provides you a whole bunch of utilites like version management as well as Configuration management wherein you edit the Web.Config properties, very handy for deployment scenarios where you dont have Visual Studio 2005 and hence no Website Administration Tool.
Client Script Call Back allows you to AJAXify your page
While the whole world is running behind installing AJAX Toolkits including ASP.NET AJAX, ASP.NET 2.0 had this little nice feature called "Client Script Callback Manager" which allows you to make asynchronous calls to your server side methods and hence enabling partial page update or remote scripting or AJAX enabled, whatever way you like to call it. For more information check out
TreeView - You always wanted, now it is here
While a TreeView is such a popular control required, it was always missing in the earlier versions of ASP.NET. Users have to resort to using the less extensible "IE Webcontrols" or run behind third party solutions. ASP.NET 2.0 comes with a built-in TreeView control which is tested and works fine across Firefox, etc., and also provides properties and methods including On Demand (again AJAX Feature) loading of child nodes. Check my own blog's ASP.NET 2.0 Category articles for a few posts on TreeView
MultiView - Finally there is a Tab Control
As much as TreeView is important, a Tabbed Control was always required to show different portions of page in the same page. The MultiView provides you a tabbed interface for showing different sections of your page within the same page, on demand. It is a cool utility to provide Tabbed interface to your pages.
Subsitution Control
Whenever you Cache enable your page, all portions of your page become more or less static until the Cache gets invalidated. However, if you have a little nifty section of your page (Cricket Score? eh ? ) that needs to always retrieve fresh data, dont blame Cache and remove it from the whole page. Use the substitution control which can help you in making a portion of your page dynamic using the method you provide to use for constant update.
PreviousPage - How I wonder what was there (in the previous page)
Dealing with web applications is such a nuisance considering that it is state less and we need to preserve values across postback. Session has been beaten to death though its still a good way. But what if I want to retrieve the TextBox value of the previous page, use the Page.PreviousPage property to retrieve the control's reference and get the value of the TextBox. Of course this works only if you were in the previous page before coming to this page, but that can be checked and validated.
Default Button - Hit Enter Key and get what you want it to do
Enter Key has always been challenging in form submission and if you have multiple buttons in your page, you never know which one is firing when user hits enter. I have seen sites till date which allow me to enter registration information and when I press "Enter" to complete take me to the "Search" Page since it is the first button on the top of the page. With ASP.NET 2.0, the Default Button is a property that can be set at the Form level / panel level to specify which button should be fired when the user hits the "Enter" Key and accordingly act. Its a cool utility which provides complete control of where you want to fire an event upon user hitting the "Enter" button.
You are already writing a Mobile Applicaiton
In ASP.NET 1.x versions you had to use the MMIT (Microsoft Mobile Internet Toolkit) for writing pages that can be rendered on Mobile Devices. However, with ASP.NET 2.0 your pages that run on the browser, automatically run on mobile devices since the rendering capabilities and the user agent is automatically determined before the page is rendered. So, your ASP.NET 2.0 Page can also be viewed over devices, without additional effort from you.
I think I tried to provide 10 things you might not know about ASP.NET 2.0 and that is the reason, I have avoided mentioning things like GridView, MasterPages, Themes etc., which have been dealt with for a long time now.
Many of these are little things which can help with your web development and if you have issues with these, we would like to hear your development experiences, so please post them in your comments.
So, here it is, 10 things you might not know about ASP.NET 2.0
No need to press "Ctrl + Shift + B" (Build) for everything
When working with ASP.NET 2.0 and Visual Studio 2005, you dont need to press Ctrl + Shift + B (in other words build) to check every change you make to the source / design. Both the ASPX Page and Code behind files are compiled dynamically when you run the page and if there is a change, the source / design is recompiled accordingly so you dont have to rebuild the solution. In fact the only instance where you want to rebuild the solution is when you add an external DLL reference / modify and add an external DLL again, where I have found some cases when the change is not reflected.
This would save a lot of time particularly in big projects where you have lot of source files and building all of them for each and every change would consume lot of time.
Data Source doesnt always need to be SQL DataSource
When working with Data Sources most of us would have seen the SQL Data Source examples and always said "Ah, this is good for Demo but what about enterprise applications where I cannot have the SQL Query or Stored Procedure mentioned in the Data Source definition in the ASPX Page" Object Data Source accepts your business layer methods as inputs and very well acts as a bridge between your business layer.
Web.Config is more friendly to IIS
Web.Config is one of the favourite things and the toughest nuts to crack in terms of editing them. While most of us might have seen Web.Config edited using the Website Administration Tool (if it sounds like alien to you or have never tried out, go to "Website - ASP.NET Configuration" in Visual Studio 2005), little is known that you can edit the Web.Config settings using IIS - yes Internet Information Services.
When you install ASP.NET 2.0 (gets installed when you install Visual Studio 2005 as in most of the cases), you get the "ASP.NET" Tab for virtual directory properties and that provides you a whole bunch of utilites like version management as well as Configuration management wherein you edit the Web.Config properties, very handy for deployment scenarios where you dont have Visual Studio 2005 and hence no Website Administration Tool.
Client Script Call Back allows you to AJAXify your page
While the whole world is running behind installing AJAX Toolkits including ASP.NET AJAX, ASP.NET 2.0 had this little nice feature called "Client Script Callback Manager" which allows you to make asynchronous calls to your server side methods and hence enabling partial page update or remote scripting or AJAX enabled, whatever way you like to call it. For more information check out
TreeView - You always wanted, now it is here
While a TreeView is such a popular control required, it was always missing in the earlier versions of ASP.NET. Users have to resort to using the less extensible "IE Webcontrols" or run behind third party solutions. ASP.NET 2.0 comes with a built-in TreeView control which is tested and works fine across Firefox, etc., and also provides properties and methods including On Demand (again AJAX Feature) loading of child nodes. Check my own blog's ASP.NET 2.0 Category articles for a few posts on TreeView
MultiView - Finally there is a Tab Control
As much as TreeView is important, a Tabbed Control was always required to show different portions of page in the same page. The MultiView provides you a tabbed interface for showing different sections of your page within the same page, on demand. It is a cool utility to provide Tabbed interface to your pages.
Subsitution Control
Whenever you Cache enable your page, all portions of your page become more or less static until the Cache gets invalidated. However, if you have a little nifty section of your page (Cricket Score? eh ? ) that needs to always retrieve fresh data, dont blame Cache and remove it from the whole page. Use the substitution control which can help you in making a portion of your page dynamic using the method you provide to use for constant update.
PreviousPage - How I wonder what was there (in the previous page)
Dealing with web applications is such a nuisance considering that it is state less and we need to preserve values across postback. Session has been beaten to death though its still a good way. But what if I want to retrieve the TextBox value of the previous page, use the Page.PreviousPage property to retrieve the control's reference and get the value of the TextBox. Of course this works only if you were in the previous page before coming to this page, but that can be checked and validated.
Default Button - Hit Enter Key and get what you want it to do
Enter Key has always been challenging in form submission and if you have multiple buttons in your page, you never know which one is firing when user hits enter. I have seen sites till date which allow me to enter registration information and when I press "Enter" to complete take me to the "Search" Page since it is the first button on the top of the page. With ASP.NET 2.0, the Default Button is a property that can be set at the Form level / panel level to specify which button should be fired when the user hits the "Enter" Key and accordingly act. Its a cool utility which provides complete control of where you want to fire an event upon user hitting the "Enter" button.
You are already writing a Mobile Applicaiton
In ASP.NET 1.x versions you had to use the MMIT (Microsoft Mobile Internet Toolkit) for writing pages that can be rendered on Mobile Devices. However, with ASP.NET 2.0 your pages that run on the browser, automatically run on mobile devices since the rendering capabilities and the user agent is automatically determined before the page is rendered. So, your ASP.NET 2.0 Page can also be viewed over devices, without additional effort from you.
I think I tried to provide 10 things you might not know about ASP.NET 2.0 and that is the reason, I have avoided mentioning things like GridView, MasterPages, Themes etc., which have been dealt with for a long time now.
Many of these are little things which can help with your web development and if you have issues with these, we would like to hear your development experiences, so please post them in your comments.

0 comments:
Post a Comment