UpdatePanel不适用于按钮

时间:2014-01-14 10:53:23

标签: c# asp.net-ajax

  

我有我的代码将值插入数据库并在插入数据后    ModalPopupExtender 显示并在点击确定按钮时触发事件   重新加载页面。但我不希望我尝试使用所有分页重新加载   更新面板确定事件无效。

 <asp:Panel ID="PostPanel" runat="server" Style="display: none;">
            <div class="modalPopup">
                <div class="PopupBody">
                    <p class="ads-text">
                       GO </p>
                </div>
                <div class="Controls">
                    <div class="post">
                        <asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
                            OnClick="btnOkay_Click" />
                    </div>
                </div>
            </div>
        </asp:Panel>

<cc1:ModalPopupExtender ID="ModelExtenderPost" OkControlID="btnOkay" runat="server"
    TargetControlID="HiddenField22" PopupControlID="PostPanel" PopupDragHandleControlID="PopupHeader"
    Drag="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:HiddenField ID="HiddenField22" runat="server" />




 protected void btnOkay_Click(object sender, EventArgs e)
{

   Response.Redirect(Request.Url.ToString(), true);
}

1 个答案:

答案 0 :(得分:0)

使用asp.net中的updatepanel 在页面顶部:

<%@ Page Title="" Language="C#" MasterPageFile="~/..." EnableEventValidation="false" AutoEventWireup="true" ....

和ypur小组:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode= "Conditional">
<ContentTemplate>
   <div class="modalPopup">
            <div class="PopupBody">
                <p class="ads-text">
                   GO </p>
            </div>
            <div class="Controls">
                <div class="post">
                    <asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
                        OnClick="btnOkay_Click" />
                </div>
            </div>
        </div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnOkay" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>