Problem and Solutions



How to make more than one default button in (Enter Key Problem)


I have 2 buttons on my page. First one is for search and second one is login.

When I enter user id and password and hit on the enter button, it executes the search button. it is not executing login button.

When i enter user id and password and hit enter key login button should execute as well as enter keyword in search box then search button should execute.

Please someone help me to solve this problem.

Posted by: Sam
On 04 Jan 2012 | Views: 2364 | Categories: ASP.NET
 On 04 Jan 2012 01:18:43 PM


Form and panel has DefaultButton property in 2.0 and latest version.

Set DefaultButton property problem will be solved.


<asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch">

Enter Keyword:
<asp:TextBox ID="txtKeyword" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search"
onclick="btnSearch_Click" />

<asp:Panel ID="pnlLogin" runat="server" DefaultButton="btnLogin" >
Enter Username:
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
Enter Password:
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"> </asp:TextBox>
<asp:Button ID="btnLogin" runat="server" Text="Login"
onclick="btnLogin_Click" />
 On 05 Jan 2012 02:08:35 AM
Hi Michael,

Thank you so much. its working fine.
Post your Solutions  


Other lins

.Net Techies
Other lins