繁体   English   中英

asp.net按钮事件未触发(Internet Explorer)

[英]asp.net button events not firing (Internet Explorer)

我有一个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;
    }
}

谢谢,克雷格

这是一个完整的猜测,但是由于您的.ascx和后面的代码似乎没有什么问题,所以我唯一想到的就是将它们包装在调用控件的.aspx中的<form>元素中。

由于所有页面都是html表单,因此添加嵌套页面会破坏.net设置内容的所有魔力,并可能导致这种行为,因为该页面的形式与预期的完全不同,因此无法识别值。 但是,仍然有一个完整的猜测,也许拥有.aspx代码将有助于诊断?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM