Implement Bootstrap Modal Popup Dialog Box inside Master Page in ASP.Net

Last Reply on Dec 17, 2015 05:10 AM By aditya2267

Posted on Dec 16, 2015 03:36 AM

Hello all,

with reference to the below article,

I;m trying to implelement the same from aspx master page. But the modal is not showing on button click from code behind.

Posted on Dec 17, 2015 05:10 AM

Hi nadeem1218,

i can see many missing things in your code.

  1. Script is placed inside ContentPlaceHolder on Master page.
  2. Bootstrap and jquery both js missing.
  3. two title tag in head of master.
  4. ShowPopup Javascript function missing.

However i have corrected all the things in below sample code. please refer it, it works.


<head runat="server">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap -->
    <link href=""
    <script src="" type="text/javascript"></script>
    <script src=""
    <script src=""></script>
    <script src=""></script>
    <asp:ContentPlaceHolder ID="head" runat="server">
    <script type="text/javascript">
        function ShowPopup() {
        .modal-backdrop { height: 100%; }
    <form runat="server">
    <asp:ContentPlaceHolder ID="MainContent" runat="server" />

aspx Page:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="head">
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <div class="modal fade" id="myModal" style="display: none">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">
                                Registration done Successfully</h4>
                        <div class="modal-body">
                            Test Modal
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                            <button type="button" class="btn btn-primary">
                                Save changes</button>
            <asp:Button runat="server" ID="btnShowPopup" Text="Test Show" OnClick="btn_click"
                CssClass="btn btn-primary" data-toggle="modal" data-target="#myModal" />

Code Behind:

protected void btn_click(object sender, EventArgs e)
    ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);