I'm speaking at the Orlando ASP.NET Connections conference this week (one of my favorite conferences to attend) and had an opportunity to attend Scott Guthrie's ASP.NET 2.0 Tips and Tricks session which was really good. I've had a chance to play around with most of the features but there were a few that I hadn't tried out yet. A few of my favorite topics covered included:
- Taking applications off-line: Adding an app_offline.htm file into the root of an ASP.NET Website automatically shuts down the application until the file is removed. That's a great feature for people that need a friendly message to be displayed while a particular server box is being updated.
- Cross-page postbacks: <asp:button PostBackUrl=“PostbackPage.aspx” runat=“server”/>. I've used these quite a bit in ASP.NET V2 and it's a really nice feature especially when a postback really needs to go to a different page such as a search page.
- Setting a default button: <form DefaultButton=“btnSubmit” runat=server>. This allows someone to hit the enter key and still have the button's postback event handler hit in the code-behind page. The DefaultButton property can also be added to Panel server controls.
- Setting default focus: <form DefaultFocus=“txtName” runat="server">. This allow you to easily set the default focus to a control in your form without writting code. The Page class's SetFocus() method can also be called. Controls also expose a Focus() method.
- Setting focus during a validation error: The validation controls now allow you to easily set focus on a control in error using the SetFocusOnError property. Validation controls also work properly in browsers such as FireFox.
ErrorMessage="TextBox3 is empty" ControlToValidate="TextBox3"
- Register server controls and user controls in web.config: You can now register frequently used server controls and user controls (ones used across multiple pages) in web.config which avoids having to define the <%@ Register %> directive in each page (which I personally never liked):
<add tagPrefix="acme" tagName="uc" src="~/UserControls/Header.ascx" />
<add tagPrefix="my" namespace="CustomControls.Basic" assembly="CustomServerControl" />
- CSS Control Adapters: Prefer to use CSS and divs instead of tables for the HTML output by ASP.NET server controls? Now you can with CSS adapters.
- RSS Tookit: Easily consume and create RSS feeds with the RSS Toolkit.
Additional topics were covered but these items were some of my favorites simply because they help with some of the stuff that was somewhat of a pain in ASP.NET 1.1 and are very simple to use.