I have created 2 modaldialogs. My problem is that I need to show them from server-side if a few conditions are met (after clicking a button). I've been googling around and there was a solution to add the extender to an invisible control and launch it from code. But since there's nothing showing, I suppose I'm doing something wrong. I tried it with a click on the linkbutton, to see if that was working and this is showing the dialog.
Thanks in advance.
Markup:
<asp:LinkButton ID="lnkPrompts" runat="server">LinkButton</asp:LinkButton>
<asp:ModalPopupExtender ID="lnkPrompts_ModalPopupExtender" runat="server"
BackgroundCssClass="modalBackground" Enabled="True"
TargetControlID="lnkPrompts" PopupControlID="pnlPromptModal"
OkControlID="pnlPromptModal">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlPromptModal" runat="server" Width="350px" Height="70px"
CssClass="modalPopup" Style="display: none;">
Some text
<div style="">
<asp:Button ID="btnModalPromptOk" runat="server" Text="OK" />
</div>
</asp:Panel>
On server-side:
protected void btnViewPrompts_Click(object sender, EventArgs e)
{
if (conditionMet)
{
Response.Redirect("IvrPrompts.aspx?Id=" + breakdownView.Id);
}
else
{
//ToDo: Show modaldialogbox
lnkPrompts_ModalPopupExtender.Show(); //This does nothing...
}
}
The times that I've used the ModalPopupExtender in the way you're describing, I've wrapped them in an UpdatePanel. This is the only way to have the server side "initiate" the action like you're describing.