Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm struggling with an ASP.NET site I'm making. I have a "master" page which contains a DIV header with a search box/button combo. The form tag rolls over the content section too.
ASP.NET
<form id="form1" runat="server">
<div class="content" id="Div1"  runat="server">
  <asp:Panel DefaultButton="searchbutton">
    <asp:TextBox ID="searchquery" runat="server" class="searchbox" />
    <asp:Button ID="performsearch" runat="server" class="searchbutton" PostBackUrl="Search.aspx" />
  </asp:Panel>
</div>


Inside my "login" page, I have another button for logging in
ASP.NET
<asp:Panel DefaultButton="loginbtn">
<table style="width: 100%; padding: 4px 4px 4px 4px; margin: 4px 4px 4px 4px;">
  <tr>
    <td style="text-align: center;" colspan="2">Returning User?</td>
  </tr>
  <tr>
    <td style="width: 50%; text-align: right;">Email Address</td>
    <td style="width: 50%; text-align: left;"><asp:TextBox runat="server" ID="usrname" name="usrname"></asp:TextBox></td>
  </tr>
  <tr>
    <td style="width: 50%; text-align: right;">Password</td>
    <td style="width: 50%; text-align: left;"><asp:TextBox runat="server" TextMode="Password" ID="passwrd" name="passwrd"></asp:TextBox></td>
  </tr>
  <tr>
    <td colspan="2" style="text-align: center;"><asp:Button runat="server" ID="loginbtn" name="loginbtn" Text="Log In" /></td>
  </tr>
</table>
</asp:Panel>


Now I read that the only way to handle users pressing the enter key was to seperate the sections in Panels, however, even in my passwrd box, if I press enter, I get directed to Search.aspx instead of posting back to my Login page.

Have I done something wrong? or is there a different way of doing it?

Cheers
Posted

Urm, figured it out - I was missing
ASP.NET
runat="server"
on my panels. D'oh
 
Share this answer
 
if possible set you defult button for form

C#
<form id="form1" runat="server" defaultbutton="loginbtn">


also helps you
 
Share this answer
 
Comments
MarqW 11-Apr-12 11:21am    
I tried that - but again, didn't put the runat=server. Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900