June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to specify that a specific control should be given focus when the page is rendered and sent to the user.
Create a JavaScript statement that sets the focus, and add it to the page using the Page.RegisterStartupScript method.
The ASP.NET Web controls do not provide any way to programmatically set the focus. They do provide a TabIndex property that allows you to set the tab order, but this property only applies to Microsoft Internet Explorer and cannot be used to programmatically set the focus to the control of your choice. To overcome this limitation, you need to add a little snippet of JavaScript code.
The following subroutine generalizes this task. It accepts a reference to any ...
Read now
Unlock full access