Thursday, April 19, 2007

Seven Simple ASP.NET 2.0 Tips and Tricks that You May (or may not) have Heard About

Dan Wahlin has posted seven great ASP.NET 2.0 Tips and Tricks that you should know.
Here is a preview of all seven tips

1. Maintain the position of the scrollbar on postbacks: In ASP.NET 1.1 it was a pain to maintain the position of the scrollbar when doing a postback operation.

2. Set the default focus to a control when the page loads: This is another extremely simple thing that can be done without resorting to writing JavaScript.

3. Set the default button that is triggered when the user hits the enter key: This was a major pain point in ASP.NET 1.1 and required some JavaScript to be written to ensure that when the user hit the enter key that the appropriate button on the form triggered a "click" event on the server-side.

4. Locate nested controls easily: Finding controls within a Page's control hierarchy can be painful but if you know how the controls are nested you can use the lesser known "$" shortcut to find controls without having to write recursive code.

5. Strongly-typed access to cross-page postback controls: This one is a little more involved than the others, but quite useful.

6. Strongly-typed access to Master Pages controls: The PreviousPageType directive isn't the only one that provides strongly-typed access to controls.

7. Validation groups: You may have a page that has multiple controls and multiple buttons. When one of the buttons is clicked you want specific validator controls to be evaluated rather than all of the validators defined on the page.

Read the complete article here:

No comments: