I have 2 ajax modal popups (I've omitted most of the code), when I close them I want to rebind the page behind which contains a datagrid. I have tried trying to trap the postback control and rebinding only when that control is listed as there are other postback controls on the page, but it's not working. Any help would be greatly appreciated...
<%@ 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"> </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>
Code behind...
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(); }