Saturday, April 29, 2006

Asp.Net 2.0 Tips&Tricks

1. App_offline.htm
It Enables you to gracefully take a server application “offline” for maintenance.It is very much useful when making big changes/upgrades.This feature can be enabled by adding a “app_offline.htm” file at the root of an applicationwhich causes ASP.NET app to shutdown and causes all dynamic requests to return app_offline.htm file contents

Tip: Make sure the app_offline.htm file is large enough (512 bytes) to disable the IE “friendly http errors” feature

2.Cross Page Post-backs
In asp.net 2.0 you can directly postback to another page from a server contro.You can do it by using “PostBackUrl” property .It can be declaratively or programmatically set.Another advantage is that Postback “target page” has full access to server controls for “originating page”.You can access controls via “Page.PreviousPage” property

3.Validation Groups
It Enable validation controls to only apply in response to a specific button/action by the use of “ValidationGroup” property

4.MaintainScrollBackPosition
It enable pages to automatically maintain the current scroll position across postbacks by using the following page directive attribute

5.Default Button
It Enable developers to identify default button behavior when the “enter” key is hit .It Can be set on control to identify default for the form.it Can also be set on control to override form behavior when an input control has focus in the browser

6.Default Focus.
It enable developers to identify default focus behavior when page is loaded .It can an be set on control to identify default for the form .it an also be programmatically set:
Page.SetFocus(control)TextBox.Focus()

7.SetFocusOnError
It enable developers to force focus on a control when a validation error occurs by setting as a property on the validation control

8.Client Script Handlers
In Asp.net 2.0 new features called client side script handler is introduce to wtite events on both clien and server site.

9.Web.Config Registration of Controls
Server controls can now be registered within web.config files instead of on every page

10.CSS Control Adapters
ASP.NET 2.0 supports a “control adapter” architecture that allows developers to customize and override rendering semanticsEg: use CSS instead of tables/inline-styles.It can be enabled by adding a .browser file within /app_browsers directory that maps a control to a control-adapter class