这是我的Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string Error = "";
//Any attempt to login from another page met with an error is bounced here. We then display the error message. We do this because many other pages have a css dropdown with limited options and no warning label.
if (!IsPostBack)
{
try { Error = Session["LoginError"].ToString(); }
catch { }
Session["LoginError"] = "";
// if (Error.Length > 0) { WarningLbl.Text = Error; }
LoadPageText();
}
else
{
Enroll();
}
}
在PostBack上的,当我按下enter ... Enroll();执行,但它也执行以下button_event
这是ASP
<td style="width: 75px; text-align: center; vertical-align: top;">
<asp:Button ID="FrenchBtn" runat="server" BackColor="Transparent" BorderStyle="None" CssClass="clickable" Font-Bold="True" Font-Names="Arial" Font-Size="X-Small" ForeColor="White" OnClick="FrenchBtn_Click" onmouseout="this.style.color = 'white';" onmouseover="this.style.color = 'yellow';" Text="Button" />
</td>
这是CSS:
.clickable {
z-index: 0;
cursor: pointer;
}
protected void FrenchBtn_Click(object sender, EventArgs e)
{
SessionVars.Current.varLanguage = "French";
Response.Redirect("~/Account/Enroll.aspx");
}
注意:我没有按下按钮执行此操作;然而,这是第一个&#34;可点击的&#34;屏幕上的事件。这为什么要执行?是否有一些属性或属性或序列导致执行此操作?
答案 0 :(得分:0)
这称为表单的默认提交按钮。确保它没有在表单中或页面上的其他位置注册(检查放置按钮的容器,页面和面板具有此功能)
<form id="form1" runat="server" defaultbutton="FrenchBtn">
http://www.codeproject.com/Tips/229011/How-to-make-a-button-the-default-button-on-enter