问题
I want to open modal window when user click create new link.
Mvc automatically generates create view in default but it open in another page. I want it to load in Bootstrap pop-up
回答1:
Please Use below example.
Button/Link, Here I am take button
<button type="button" name="btnLink" id="btnLink">Open Pop</button>
Model Pop : put ending of the page
<div class="modal fade" id="ModalPopUp" role="dialog">
<div class="modal-dialog err-pop" style="">
<div class="modal-content">
<div class="modal-header">
<button id="DivClose" type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body" style="text-align:center;">
Put Your Html Element Here
</div>
</div>
</div>
Script:
<script src="https://code.jquery.com/jquery-1.10.0.min.js"
integrity="sha256-2+LznWeWgL7AJ1ciaIG5rFP7GKemzzl+K75tRyTByOE="
crossorigin="anonymous"></script>
<script>
$("#btnLink").click(function () {
$('#ModalPopUp').modal('show');
})
</script>
来源:https://stackoverflow.com/questions/54277982/modal-pop-up-in-mvc-5