Hi i have created a class as follows which will create a dynamic popup
public static void createModal()
{
Button btnShow = new Button();
btnShow.ID = "btnCancel";
Panel p = new Panel();
p.ID = "ModalPanel";
p.Height = Unit.Percentage(300);
p.Width = Unit.Percentage(800);
Button btnCancel = new Button();
btnCancel.Text = "Close";
btnCancel.ID = "btnCancel";
Page page = HttpContext.Current.CurrentHandler as Page;
AjaxControlToolkit.ModalPopupExtender modalPop = new AjaxControlToolkit.ModalPopupExtender();
modalPop.ID = "popUp";
modalPop.PopupControlID = p.ID;
modalPop.TargetControlID = btnShow.ID;
modalPop.DropShadow = true;
modalPop.CancelControlID = btnCancel.ID;
//page.Form.Controls.Add(p);
page.Form.Controls.Add(btnCancel);
page.Form.Controls.Add(modalPop);
}
And in my page my design is as follows
<asp:ScriptManager ID="script" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<%--<Triggers>
<asp:PostBackTrigger ControlID="btnShow" />
</Triggers>--%> <ContentTemplate>
<asp:Button ID="btnShow" runat="server" Text="Open" OnClick="btnShow_Click"></asp:Button>
</ContentTemplate>
</asp:UpdatePanel>
This is my code on button click to show the popup
protected void btnShow_Click(object sender, EventArgs e)
{
common.createModal(btnShow);
}
If i didnot include the trigger on the page modal is not showing, but if I include the trigger modal popup is showing, can this be achieved with out registering the triggers