In this article I will explain with an example, how to open (show) ASP.Net AJAX ModalPopupExtender Modal Popup from Code Behind (Server Side) in ASP.Net using C# and VB.Net.
 
 
HTML Markup
First we need to register the AJAX Control Toolkit on the page.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
The following HTML Markup consists of an ASP.Net AJAX ModalPopupExtender Modal Popup, its associated Panel control and a hidden LinkButton whose ID is set as TargetControlID for the ASP.Net AJAX ModalPopupExtender Modal Popup.
Note: This article will illustrate how to open ASP.Net AJAX ModalPopupExtender Modal Popup from Code Behind (Server Side) in ASP.Net, since it is mandatory to set TargetControlID for an ASP.Net AJAX ModalPopupExtender Modal Popup, the concept of hidden LinkButton is used.
The Panel control contains a Button (btnHide) whose ID is set as CancelControlID for the ASP.Net AJAX ModalPopupExtender Modal Popup. When the Button (btnHide) is clicked, the ASP.Net AJAX ModalPopupExtender Modal Popup will close.
Note

: For more details on using the ASP.Net AJAX ModalPopupExtender please refer my article Building Modal Popup using ASP.Net AJAX ModalPopupExtender Control
 
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server"
    PopupControlID="pnlPopup" TargetControlID="lnkDummy" BackgroundCssClass="modalBackground" CancelControlID = "btnHide">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none">
    <div class="header">
        Modal Popup
    </div>
    <div class="body">
        This is a Modal Popup.
        <br />
        <asp:Button ID="btnHide" runat="server" Text="Hide Modal Popup" />
    </div>
</asp:Panel>
 
 
Open (Show) ASP.Net AJAX ModalPopupExtender Modal Popup from Code Behind (Server Side) in ASP.Net
Inside the Page Load event if the page, the ASP.Net AJAX ModalPopupExtender Modal Popup is opened (shown) using its Show method.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        ModalPopupExtender1.Show();
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        ModalPopupExtender1.Show()
    End If
End Sub
 
 
Screenshot
Open (Show) ASP.Net AJAX ModalPopupExtender Modal Popup from Code Behind (Server Side) in ASP.Net
 
 
Demo
 
 
Downloads