Monday, November 3, 2008
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">"
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.