Richu R
Richu R

Reputation: 71

Boostrap 4 modal is not working in asp.net

I am trying to add modal popup of bootstrap 4 within my ASP.NET page. Note when I tried to popup the modal it makes nothing but a postback only. I saw some suggestions on the net saying add code for modal outside form tag, update panel etc but nothing works for me. I checked the same code in a plain html page and it's working perfectly there. Note that I have an update panel within my page. I tried adding code both inside and outside of this update panel. I don't know what's wrong with it?? Any help will be appreciated.

Here is my code.

 <button id="btnModal" class="btn btn-info" >Show Modal</button>
    <div class="modal fade" id="BootstrapModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h6 class="modal-title">warning!</h6>
                </div>
                <div class="modal-body">
                    Select row(s) to delete.
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function () {
            $('#btnModal').click(function () {
                $("#BootstrapModal").modal("show");
            });
        });

Jquery and everything are there and works fine. But this modal calling gives me a postback only....

Upvotes: 0

Views: 909

Answers (1)

Gagan Deep
Gagan Deep

Reputation: 1509

Add these to your button

<button type="button" id="btnModal" class="btn btn-info" data-toggle="modal" data-target="#BootstrapModal" >Show Modal</button>

and remove your document.ready function.

Upvotes: 1

Related Questions