关闭modalpopup时刷新页面

问题描述 投票:1回答:0

我有2个Ajax模态弹出窗口(我省略了大部分代码),当我关闭它们时,我想重新绑定包含数据网格的页面。 我试图尝试捕获回发控件并仅在该控件被列出时重新绑定,因为该页面上还有其他回发控件,但它不起作用。 任何帮助将不胜感激...

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Frm.aspx.cs" Inherits="Prj.Frm" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript" language="javascript" src="Scripts/script.js"> </script>
    <script src="Scripts/jquery-1.8.3.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.9.2.custom.js" type="text/javascript"></script>
      <link href="Styles/post_ui.css" rel="stylesheet" type="text/css" />
    <asp:ScriptManager runat="server" ID="scriptManager" EnablePageMethods="true">
    </asp:ScriptManager>
<asp:ModalPopupExtender ID="mpeNV" BehaviorID="mpeNV" runat="server"
        TargetControlID="btnShowPopupNV" PopupControlID="pnlpopupNV" CancelControlID="imgCancelNV"
        BackgroundCssClass="modalBackground" />
    <asp:Panel ID="pnlPopupNV" runat="server" Width="700px" Style="display: none;"
        class="ModalPanel">
        <asp:Panel ID="pnlInnerNV" runat="server" BackColor="white" Width="700px">
            <table style="width: 700px;" >
                <tr>
                    <td width="10px">
                        &nbsp;
                    </td>
                    <td align="left">
                        <asp:Label ID="Label3" runat="server" Text="New" CssClass="norm_w" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="right">
                        <img src="images/close.png" id="imgCloseNV" alt="" style="cursor: hand" onclick=" $find('mpeNV').hide();"
                            width="15" height="15" />
                    </td>
                </tr>
        <!--Popup Controls Here -->
            </table>
      <asp:Button ID="imgCancelNV" Text="Cancel" runat="server" OnClick="imgCancelNV_Click" />
        </asp:Panel>
    </asp:Panel>
<!--Popup 2 Here -->
<div>
        <asp:DataGrid ID="dg" runat="server">
 </asp:DataGrid>
    </div>
</asp:Content> 

背后的代码...

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

               //Do some stuff then

                BindData();
            }
            else
            {
                string CtlName = Page.Request.Params.Get("__EVENTTARGET");
                if (!string.IsNullOrEmpty(CtlName))
                {
                    // Looking for the control ID
                    // string sControl = Page.FindControl(CtlName).ClientID;
                    if ((CtlName.Contains("dg")) || (CtlName.Contains("imgCancel")) || (CtlName.Contains("imgCancelNV")))
                    {
                        BindData();
                    }
                }

            }


        }

    protected void imgCancelNV_Click(object sender, EventArgs e)
            {
                this.mpeNV.Hide();
                //Have tried this with and without binddata
               BindData();
            }
c# data-binding modalpopupextender
© www.soinside.com 2019 - 2024. All rights reserved.