interviews.dotnetthread.com

↑ Grab this Headline Animator

Monday, November 3, 2008

How to set default button in ASP.NET page with more than one submit button.

To set default button in ASP.NET form if we have multiple submit buttons in a single form to handle Enter key functionality.

Say we have a form as below with two submit buttons each corresponding to separate inputs.

Now when focus on TextBox1 if user press on Enter button, Submit1 should fire and with focus on TextBox2 Enter button should fire Submit2.


For this we can use separate Panels(<asp:Panel<) for each Submit categories and set "DefaultButton" property of "Panel1" to "Submit1" and Panel2 to "Submit2" button.
"<asp:Panel ID="aa" runat="server" DefaultButton="Button1">"

If want to set a default button and default focus for Form the we can use defaultbutton and defaultfocus properties of form tag as below.
"<form id="form1" runat=”server” defaultbutton=”Button1″defaultfocus=”txtName">"

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles