Bootstrap Modal RRS feed

  • Question

  • User1979860870 posted


      Instead of below code i want to create BootStrap Modal & how to replace this code with Modal 

    catch (Exception ex)
                    ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + CommonFunction.ErrorConnection + "');", true);

    <script type="text/javascript">
                function ShowPopup(message) {
                    $(function () {
                            title: "Message Box",
                            buttons: {
                                Close: function () {
                            modal: true


    Sunday, May 23, 2021 5:52 AM

All replies

  • User-1330468790 posted

    Hi jagjit saini,


    You can directly refer to the documentation about how to call a modal via Javascript on Bootstrap website:



    More details, you could refer to below codes:


    <head runat="server">
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/>
        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
        <form id="form1" runat="server">
                <!-- Button trigger modal -->
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
                    Launch demo modal
                <!-- Modal -->
                <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                            <div class="modal-body" id="modalContent">
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                <button type="button" class="btn btn-primary">Save changes</button>
            <asp:Button ID="ShowModalBtn" runat="server" Text="Show Modal" OnClick="ShowModalBtn_Click" />
            <script type="text/javascript">
                function ShowPopup(message) {

    Code behind:

     protected void ShowModalBtn_Click(object sender, EventArgs e)
                ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('this is an error');", true);



    Hope helps.

    Best regards,


    Monday, May 24, 2021 9:05 AM