html - 触发没有按钮的模态
问题描述
我有一个非常基本的问题。我正在开发 .cshtml 格式的登录页面。现在我想在不使用按钮的情况下在引导程序中实现模式。就像登录凭据中的“条件错误”一样,然后显示模式。我给你下面的条件。从技术上讲,我看到很多带有按钮的引导程序,但我不希望那样。我希望模态自动执行。或模态的 HTML 部分在没有数据目标的情况下触发。
@if (ViewContext.ModelState.IsValid == false)//condition for login failure, its in a file called _validation summary.cshtml
{
// Modal html we may change it.
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body…</p>
</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 -->
}
提前感谢,杰伊
解决方案
您可以使用 JQuery 来调用模式,例如
$('#modalId').modal("show");
$('#modalId').modal("hide");
$('#modalId').modal("toggle");
推荐阅读
- sql-server - 如何更新 SQL Server 以恢复数据库备份?
- c# - C# 使用替换构建排列,但如果位置中不存在则跳过
- c# - 保留来自 dataReader c# 的 int 变量值
- python - Plotly:如何使所有地块灰度化?
- c# - Entity Framework Core 5 主键问题
- powershell - 在同一终端中执行字符串
- openlayers - 是否有将 Openlayers 范围交互限制为指定数量的地理单元或度数的属性?
- html - 如何在 HTML 中保留连续的空白字符?
- path - Ubuntu 路径尝试从 snap 文件夹而不是 /usr/bin/terraform 执行
- javascript - 变量和字符串的函数参数问题