Problem and Solutions

1

Like

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


Hi

I have 2 buttons on my asp.net 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.

Thanks
Posted by: Sam
On 04 Jan 2012 | Views: 2364 | Categories: ASP.NET
Solutions(2)
 On 04 Jan 2012 01:18:43 PM
.

Hi

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

Set DefaultButton property problem will be solved.

Example:

<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>

<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" />
</asp:Panel>
 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