【发布时间】:2014-07-28 13:56:32
【问题描述】:
我有一个 asp.net 4.0 网站,可以在除早期版本的 IE 之外的所有浏览器中运行。
在 IE8 中,页面事件正在触发,但页面元素(例如用户名/密码字段)被“清空”,我看不到我做错了什么。
在 IE9 和 10 中,按钮单击事件根本不会触发。
我显然做了一些愚蠢的事情......有没有人可以指出我的愚蠢。以下是页面的精简版。
ascx.page
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="login.ascx.cs" Inherits="UserControls_login" %>
<ContentTemplate>
<fieldset class="login-form outlined-white-module">
<legend>Sign in</legend>
<asp:Panel ID="pnlSignin" runat="server" DefaultButton="cmdSignin">
<label for="username-email">Email</label>
<asp:TextBox ID="txtSigninEmail" runat="server" />
<label for="loginPassword">Password</label>
<asp:TextBox ID="txtSigninPassword" TextMode="Password" runat="server" />
<asp:Button style="margin-bottom:0px;"
CssClass="primaryAction button button-confirm" ClientIDMode="AutoID" ID="cmdSignin" runat="server" Text="Sign In" onclick="cmdSignin_Click" />
</asp:Panel>
</fieldset>
和 ascx.cs 页面
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["PreviousPage"] = Request.UrlReferrer;
//If someone is already logged in then redirect to account settings page
zAuthorised = Convert.ToString(Session["Authorised"]);
if (zAuthorised == "True")
{
Response.Redirect("/register/profile-edit/", false);
}
foreach (Node nChild in nAOI.Children)
{
if (nChild.NodeTypeAlias == "SectionHome")
{
chkAOI.Items.Add(new ListItem(nChild.Name, nChild.Id.ToString()));
}
}
}
}
protected void cmdSignin_Click(object sender, EventArgs e)
{
bool bError = false;
string zError = "";
litError.Text = "";
pnlError.Visible = false;
//Check username/password is populated
if (txtSigninEmail.Text == "")
{
txtSigninEmail.CssClass = "input-validation-error";
zError = "<li>You must specify a username or email.</li>";
txtSigninEmail.Focus();
bError = true;
}
}
谢谢, 克雷格
【问题讨论】:
-
不检查上面的代码,只关注“仅 IE” -> 启动相应的 IE 开发工具
F12,并检查console是否有任何客户端错误。它应该有助于将您指向罪魁祸首。嗯……
标签: c# asp.net internet-explorer-8 internet-explorer-9