ASP:按钮发布和面板 [英] ASP:Button Posting and Panels

查看:81
本文介绍了ASP:按钮发布和面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力制作自己的ASP.NET网站.我有一个母版"页面,其中包含带有搜索框/按钮组合的DIV标头.表单标签也将滚动到内容部分.

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.

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



现在,我了解到,处理用户按下Enter键的唯一方法是分隔面板中的各个部分,但是,即使在我的密码框中,如果按Enter,我也会定向到Search.aspx,而不是发回我的登录页面. .

我做错什么了吗?还是有其他不同的方法?

干杯



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

推荐答案

问题,发现了-我在面板上缺少
Urm, figured it out - I was missing
runat="server"

. D''哦


如果可能的话,您取消设置表单的按钮

if possible set you defult button for form

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



还可以帮助您



also helps you


这篇关于ASP:按钮发布和面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆