Home > Code > ASP.NET > Set Defaultbutton and Defaultfocus in aspx page

Set Defaultbutton and Defaultfocus in aspx page

by Narain Siddharth   on Feb 16, 2011   Category: ASP.NET   |  Views: 1293    |  Points: 25   |  Silver 


Below is the sample code for setting the default button for the page and default focus of the page

write the below code in the page load event.
Page.Form.DefaultButton = ButtonSubmit.ClientID;
Page.Form.DefaultFocus = TextBoxName.ClientID;

Suppose if your .aspx page merged with master page, write the below code for defaultbutton.
Page.Form.DefaultButton = ButtonSubmit.UniqueID;




Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts