Tuesday, June 30, 2009

Best ASP.NET coding practices

1. Use Master Pages.
For keeping UI consistency in earlier version different User controls were created and included in different pages. A master page is a template for other pages, with shared layout and functionality. The master page defines placeholders for content pages. The result page is a combination (merge) of the master page and the content page. So for applying a consistent look and feel for a whole web site Master pages is used in .Net .

2. Use Themes and Skins.
Themes is another feature of ASP.NET . Themes, or skins, allow developers to create a customized look for web applications. Using Themes, it makes simple to customize the appearance of a site and all visual elements can be customized. Themes can be applied to controls, pages, and entire sites.

3. Use separate files for JavaScript functions and include in Master pages.
It saves repetition of same JavaScript function in different files.

4. Use SiteMaps..
It saves time of coding for navigation from one page to another page in a web application.

5. Use a common Exception Handling page..
If any exception occur, catch it and redirect to a common Exception Handling page with exception details and Page name and display this information in user friendly manner in this Exception Handling page.

6. Use Web Parts..
Web Parts provides a consistent look for a site, while still allowing user customization of style and content. It contains Zone controls (areas on a page where the content is consistent) and Web part controls (content areas for each zone) which are new in .Net .

7. Use Login Controls..
Security is very important for protecting confi dential and personal information.

8. Place all code (.cs) fi les and dlls used, in App_Code folder..
In .Net , during compilation fi rst it compile code of code fi les resides in App_Code folder, so there will be no need to make reference of them.

9. Use bulk copy classes for bulk copying of data (e.g. SqlBulkCopy class in SQL .Net)..
Bulk copy classes provides the fastest way to transfer set of data from once
source to the other.

1. It helps to improve consistency and readability of code.
2. Error free work and helps to maintain the applications.
3. To improve the performance and reduce the code.

1 comment:

  1. how to customize background in c# window forms or to use themes in background.