Open HTML modal popup from C # code

I am using HTML modal,

HTML

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Server Message</h4>
            </div>
            <div class="modal-body">
                <div class="table-responsive">
                    <table class="table mb30">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th></th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>1</td>
                                <td>Return Message</td>
                                <td><asp:Label ID="Label1" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td>

                            </tr>
                            <tr>
                                <td>2</td>
                                <td>Return ID</td>
                                <td><asp:Label ID="Label2" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td>

                            </tr>
                            <tr>
                                <td>3</td>
                                <td>Return Status</td>
                                <td><asp:Label ID="Label3" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td>

                            </tr>
                        </tbody>
                    </table>
                </div>
                <!-- content1 end  -->
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
        <!-- modal-content -->
    </div>
    <!-- modal-dialog -->
</div>
<!-- modal -->

I tried to open this model from C # code after function using

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script>$('#myModal').modal('show');</script>", false);

For some reason it does not work.
I want to show this modal at the end of a save function with return values. This modal can be opened at the click of a button, but how can I open this modal from the C # function?

+4
source share
1 answer

You can do it.

Create JavaScript Function

<script>
    function ShowPopup()
    {
        $('#myModal').modal('show');
    }
</script>

Now call the function below:

ScriptManager.RegisterStartupScript(this, this.GetType(), "none", "ShowPopup();", true);
0
source

Source: https://habr.com/ru/post/1682106/


All Articles