简体   繁体   中英

asp.net button events not firing (Internet Explorer)

I have an asp.net 4.0 web site that works in all browser apart from early versions of IE.

In IE8 the page events are firing but the page elements (username/password fields for example) are being 'emptied' and the life of I can't see what I've done wrong.

In IE9 and 10 the button click events aren't firing at all.

I've obviously done something stupid...is there any chance that someone could point out my stupidity. Below is a trimmed down version of the page/s.

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>

and the ascx.cs page

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;
    }
}

Thanks, Craig

This is a complete guess, but since nothing seems wrong with your .ascx and code behind, the only thing I can think of is that you are wrapping them in a <form> element in your .aspx where you are calling the control.

Since all pages are html forms, adding a nested one would break all the magic that .net does to set things up and could result in this behavior, where it won't recognize the values because its getting a completely different form than what it expected. Still a complete guess, though, perhaps having the .aspx code would help diagnose?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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