Html 为什么我的模式没有显示在ASP.NET核心MVC的查看页面中?
我希望模式在用户成功订阅服务后弹出。html页面中的所有其他内容都会根据需要加载,但是模式不会弹出 代码如下:Html 为什么我的模式没有显示在ASP.NET核心MVC的查看页面中?,html,asp.net-core,asp.net-core-mvc,Html,Asp.net Core,Asp.net Core Mvc,我希望模式在用户成功订阅服务后弹出。html页面中的所有其他内容都会根据需要加载,但是模式不会弹出 代码如下: <body> <ul class="nav nav-tabs" style="background-color:blue; display:block; width:100%"> <li style="float:left; line-height:40px; padding:5px
<body>
<ul class="nav nav-tabs" style="background-color:blue; display:block; width:100%">
<li style="float:left; line-height:40px; padding:5px 10px 5px 10px; display:none"><a href="/Home/Subscribe" style="color:white;">Edit Profile</a></li>
@*<li style="float:right; padding: 5px 10px 5px 10px;"><a href="/Home/Edit" style="color:white;">Username: @ViewBag.username</a></li>*@
<li style="float:right; padding: 5px 10px 5px 10px;"><a href="@Url.Action("Edit","Home",new { sub_id = Context.Session.GetInt32("SubscriberNumber") })" style="color:white;">Username: @ViewBag.username</a></li>
</ul>
<div><h1 style="text-align:center;">Welcome to Service</h1></div>
<div class="modal" id="successModal" role="dialog">
<div class="modal-dialog">
<!--Modal content-->
<div class="modal-content">
<div class="modal header">
<h4 class="modal-title">Welcome to Service</h4>
</div>
<div class="modal-body">
<p>Thank you for subscribing to Haz360</p>
<p>Username: @ViewBag.username</p>
<p>Password: @ViewBag.password</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
@**@
欢迎光临服务
欢迎光临服务
感谢您订阅Haz360
用户名:@ViewBag.Username
密码:@ViewBag.Password
接近
如何在访问此页面时显示我的模态?提前感谢。您可以添加一个按钮,然后单击该按钮以弹出模式
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#successModal">
Click
</button>
点击
如果您不想要按钮,可以使用jquery
@section scripts{
<script>
$(document).ready(function () {
$('#successModal').modal('show');
});
</script>
}
@节脚本{
$(文档).ready(函数(){
$('successModal').modal('show');
});
}
测试结果:
HI@Pasindu Samaranayake,关于此案例的任何更新,如果此解决方案不起作用,您可以添加更多详细信息。@Yinqiu它起作用了。非常感谢。