Open Bootstrap Modal from code-behind

后端 未结 7 2076
梦谈多话
梦谈多话 2020-12-13 18:18

Anyone knows how to open a twitter bootstrap modal, from code behind?

I want to open the modal based on some requeriment at the moment of the save. Something like \"

相关标签:
7条回答
  • 2020-12-13 19:09

    Maybe this answer is so late, but it's useful.
    to do it,we have 3 steps:
    1- Create a modal structure in HTML.
    2- Create a button to call a function in java script, to open modal and set display:none in CSS .
    3- Call this button by function in code behind .
    you can see these steps in below snippet :

    HTML modal:

    <div class="modal fade" id="myModal">
                    <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>
                            <div class="modal-body">
                                <asp:Label ID="lblMessage" runat="server" />
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">
                                    Close</button>
                                <button type="button" class="btn btn-primary">
                                    Save changes</button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
                <!-- /.modal -->  
    

    Hidden Button:

    <button type="button" style="display: none;" id="btnShowPopup" class="btn btn-primary btn-lg"
                    data-toggle="modal" data-target="#myModal">
                    Launch demo modal
                </button>    
    

    Script Code:

    <script type="text/javascript">
            function ShowPopup() {
                $("#btnShowPopup").click();
            }
        </script>  
    

    code behind:

    protected void Page_Load(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
        this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";
    }  
    

    this solution is one of any solutions that I used it .

    0 讨论(0)
提交回复
热议问题