In this article I will explain with an example, how to close (hide) Bootstrap Modal Popup Window from Server Side (Code Behind) in ASP.Net using C# and VB.Net.
The Bootstrap Modal Popup is closed (hidden) by calling the modal function with parameter value hide using RegisterStartupScript method of ClientScript class on Sever Side (Code Behind) in ASP.Net.
 
 
HTML Markup
The following HTML Markup consists of an HTML Button element which will open the Bootstrap Modal Popup.
There’s an HTML DIV which will be displayed as Modal Popup Window using Bootstrap and it consists of a RadioButtonList and a Button wrapped inside an AJAX UpdatePanel.
The Button has been assigned a Server Side Click event handler.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!-- Bootstrap -->
<script type="text/javascript" src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
<link rel="stylesheet" href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css'
    media="screen" />
<!-- Bootstrap -->
<center>
    <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#MyPopup">
        Open Modal</button>
</center>
<!-- Modal Popup -->
<div id="MyPopup" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    &times;</button>
                <h4 class="modal-title">
                </h4>
            </div>
            <div class="modal-body">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        Do you wish to continue?
                        <asp:RadioButtonList ID="rblChoice" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Text="Yes" Value="Y" />
                            <asp:ListItem Text="No" Value="N" />
                        </asp:RadioButtonList>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnSubmit" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
            <div class="modal-footer">
                <asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="Submit" CssClass="btn btn-success" />
            </div>
        </div>
    </div>
</div>
<!-- Modal Popup -->
 
 
Closing (Hiding) Bootstrap Modal Popup Window from Server Side (Code Behind)
Inside the Button Click event handler, the Bootstrap Modal Popup is closed by calling the modal function with parameter value hide using RegisterStartupScript method of ClientScript class.
C#
protected void Submit(object sender, EventArgs e)
{
    if (rblChoice.SelectedValue == "N")
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup", "$('#MyPopup').modal('hide')", true);
    }
}
 
VB.Net
Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
    If rblChoice.SelectedValue = "N" Then
        ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "HidePopup", "$('#MyPopup').modal('hide')", True)
    End If
End Sub
 
 
Screenshot
Close (Hide) Bootstrap Modal Popup Window from Server Side (Code Behind) in ASP.Net
 
 
Browser Compatibility

The above code has been tested in the following browsers.

Internet Explorer  FireFox  Chrome  Safari  Opera 

* All browser logos displayed above are property of their respective owners.

 
 
Demo
 
 
Downloads