簡體   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