【问题标题】:Click event not working from Dialog box in asp.net单击事件在 asp.net 中的对话框中不起作用
【发布时间】:2017-06-14 20:10:01
【问题描述】:

我创建了一个从 aspx 页面打开的对话框。该对话框包含信息以及页脚上的按钮。合并和关闭。

下面是我用来打开的对话框。这已成功创建并且信息已被填充。但是,当我单击对话框的“合并”按钮时,它什么也不做,因为导航不会转移到代码隐藏文件中。

我已经在后面的代码上成功定义了 Click 事件,但我不明白为什么它没有触发它。

aspx 页面

<div class="modal-dialog" id="updateConfirmPopUp" style="display: none">
    <div class="modal-content">
        <div class="modal-header" id="popUpHeader">
            <button type="button" class="close closePopup">
                <span>&times;</span></button>
        </div>
        <div class="modal-body" id="confirmData">
            <div id="random"></div>
            <div class="dataTable_wrapper">
                <div class="table-responsive">
                    <uc:ReviewGroupGrids ID="reviewGroupCtrls" runat="Server" />
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <asp:Button ID="Button1" runat="server" Text="Review Next" OnClick="btnMerge_Click" />
            <button type="button" id="btnClosePopUp" class="btn btn-default closePopup">
                Okay</button>
        </div>
    </div>
</div>

aspx.cs 页面

protected void btnMerge_Click(object sender, EventArgs e)
    {
        try
        {
            // SessionUtility.SetSession(Constants.LASTREVIEWGROUPIDPROCESSED, this.ReviewGroup.ReviewGroupId);
            if (preventEvents)
            {
                Response.Redirect(Request.RawUrl, false);
                return;
            }


            // ensure no action taken on current review group(partially or completly)
            #region Handle review group for completly processed case
            var selectedAssignment = SessionUtility.GetSession(Constants.SELECTEDUSERASSIGNMENT) as Assignment;
            var currentReviewGroupID = hdnReviewGroupID.Value.ToString();

            if (currentReviewGroupID != selectedAssignment.ReviewGroupId)
            {
                selectedAssignment.ReviewGroupId = currentReviewGroupID;
                SessionUtility.SetSession(Constants.SELECTEDUSERASSIGNMENT, selectedAssignment);
                LoadNextReviewGroup(null, null);
                lblPreviousReviewGroupId.Text = string.Format(StaticConstants.REVIEWGROUPVALIDATIONMESSAGE, currentReviewGroupID);
                lblPreviousReviewGroupId.Visible = true;
                return;
            }


            #endregion
            if (!string.IsNullOrEmpty(selectedIds))
            {
                SessionUtility.SetSession(Constants.USERSERLECTIONROWIDS, selectedIds);
                if (BtnMerge_Click != null)
                {
                    BtnMerge_Click(sender, e);
                }
                Response.Redirect("MergeGroup.aspx", false);
            }
        }
        catch (Exception ex)
        {
            SessionUtility.SetSession(Constants.Error, ex);
            NavigationHelper.ToErrorPage(false);
        }
    }

我的客户端点击事件工作正常。唯一的问题是 onClick 事件。

【问题讨论】:

  • 你在任何地方都使用过更新面板吗?
  • 不,我没有使用更新面板
  • 我找不到属性“AutoPostBack”
  • 查看我的回答here。模态可能将按钮放在&lt;/form&gt; 之外。
  • @VDWWD:谢谢你的回答。有效。顺便说一句,是否有可能更改链接按钮。即让它看起来像一个按钮

标签: c# jquery asp.net


【解决方案1】:

HTML 按钮无法调用服务器端代码。您必须使用带有 runat="server" 标记的 asp 按钮。像

       <asp:Button ID="btnMerge" runat="server" Text="MERGE" OnClick="btnMerge_Click" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    相关资源
    最近更新 更多