ASP.NET按钮onclick后面没有到达代码

时间:2018-06-06 01:37:14

标签: c# asp.net button onclick

出于某种原因,我的asp按钮控件并没有让我的代码落后。知道为什么吗?

HTML:

<td class="auto-style2">
    <asp:Button ID="btnEmailSelectedTotal" 
        runat="server" 
        Enabled="true" 
        Text="Email Selected Members" 
        OnClick="btnEmailSelectedTotal_Click"/>                                               
</td>

代码背后:

   protected void btnEmailSelectedTotal_Click(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(GetType(), "myalert", 
            "alert('" + "Got here" + "');", true);
        //build our cust GUID list based off each row that was checked by pulling
        //the hidden data from HiddenField_CustGUID for the corresponding checked row
        var lstCustGuid = new List<string>();
        var isEmailAll = true;

        PopulateCookieValues((int)Cookie.HeaderTotal);

        //first get the check box list. If we find a list item that is 
        //un-checked, assume this is not an email all
        foreach (GridViewRow rw in GridView_TotalCounts.Rows)
        {
            var chkBx = (CheckBox)rw.FindControl("EmailCheckbox");
            if (chkBx != null && chkBx.Checked)
            {
            lstCustGuid.Add(((HiddenField)rw.FindControl("HiddenField_CustGUID")).Value);
            }
            else if (chkBx != null && !chkBx.Checked)
            {
                //this is not email all. we discovered an un-checked checkbox.
                isEmailAll = false;
            }
        }

        if (!string.IsNullOrEmpty(Cookies.Header.Total) &&
            Cookies.Header.Total == "true" && isEmailAll)
        {
            //header is checked - this is email all
            //populate it with the full email guid list from the hidden field:
            lstCustGuid = HF_Total_FullEmailList.Value.Split(',').ToList();
        }

        NavigateToSendEmail(lstCustGuid);
    }

如上所示,我点击的第一个项目是消息框提醒。甚至没有被调用。知道为什么onclick完全无视我背后的代码吗?我可以尝试纠正这个问题?

我在2个不同的浏览器中尝试了这个,并清除了缓存;没有帮助。

非常感谢您的帮助!

0 个答案:

没有答案