New Default button and the focus API in ASP.Net 2.0

Hi

One of the cool new features of ASP.NET 2.0 is the Focus API. With the help of the Focus API we can declaratively or programmatically set the focus on a specific control.

The page.SetFocus method is used to set the focus to a particular control. The method takes the ID of a control as a parameter. The ID passed is set the focus on. We can also use the DefaultFocus property of the Form element to define which element will have the focus. Also we can use the focus method of the individual control directly to set the focus.

Similar to the default focus you can also use the Defaultbutton property of the form to define the Default button for the form. The form will submit that button on the click of the enter key inside any input control inside of the Form.

Also this property can be set for a panel. If your page should have different default buttons depending on the input control that has current focus, you can wrap specific input controls in a Panel control and set the DefaultButton property of the Panel instead.

Hope this helps
Thanks
Vikram


Share this post   Email it

Feedback

Posted on 4/2/2008 6:06:48 AM

Nice One

Posted on 7/5/2008 10:47:22 PM

nice website

Posted on 9/14/2008 11:14:53 PM

Thanx a lot.

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 

Copyright © 2006 - 2010 Vikram Lakhotia