BZ这篇博客主要是为大家介绍一下MVC如何弹出模态框。本文如果有什么不对的地方,希望大神们多多指教,也希望和我一样的小菜多多学习。BZ在这里谢过各位。

首先要在页面加上一个点击事件:

@Html.ActionLink("预览","",null, new { onclick = "dianji('" + item.TypeCode + "')" });

接下来我们需要写一段JS:

<script type="text/javascript">
function dianji(obj)
{
debugger;
window.showModalDialog("/Type/May?TypeCode="+obj,null,"dialogWidth:400px;dialogHeight:500px;status:no;help:no;resizable:yes;");
}
</script>

PS:BZ写的是带有参数的事件,其中showModalDialog有三个参数,第一个是URL,第二个是要往模态框穿的数据(如果没有要传的参数就写为null,否则会影响第三参数的正常显示),第三个是所弹出的模态框的样式。

之后就是我们的模态框,需要两个引用文件:

<script src="http://libs.useso.com/js/jquery/2.1.1/jquery.min.js"></script>
<script src="~/Content/View/js/bootstrap-treeview.js"></script>
<script type="text/javascript">
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').focus();
})
</script>

BZ所说的模态框是根据Bootstrap框架提供的!!!

附上Bootstrap模态框Modal插件地址:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html

非常感谢各位观看本博客,BZ希望和更多的小菜一起成长,同样也希望大神们提出建议。如果有不足之处还望各位不吝赐教!再次感谢各位!

Bootstrap模态框(MVC)的更多相关文章

  1. js控制Bootstrap 模态框(Modal)插件

    js控制Bootstrap 模态框(Modal)插件 http://www.cnblogs.com/zzjeny/p/5564400.html

  2. Bootstrap模态框按钮

    1.触发模态框弹窗的代码 这里复制了一段Bootstrap模态框的代码 <h2>创建模态框(Modal)</h2> <!-- 按钮触发模态框 --> <but ...

  3. 解决bootstrap模态框内输入框无法获取焦点

    bootstrap 模态框中的input标签在某些情况下会无法获取焦点. 最终解决方法:去除模态框的 tabindex="-1" 属性即可

  4. Bootstrap 模态框(Modal)插件

    原文链接:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html Bootstrap 模态框(Modal)插件 模态框(Modal)是覆 ...

  5. Bootstrap 模态框在用户点击背景空白处时会自动关闭

    问题: Bootstrap 模态框在用户点击背景空白处时,会自动关闭. 解决方法: 在HTML页面中编写模态框时,在div初始化时添加属性 aria-hidden=”true” data-backdr ...

  6. 去除bootstrap模态框半透明阴影

    当使用bootstrap模态框默认自带半透明阴影,如果想要去除阴影,需要怎么做呢? 今天在项目中我遇到了这个问题,想要去除模态框的阴影,试了好久都没解决.后来问同事的时候才知道,当模态框弹出后,会加上 ...

  7. Bootstrap 模态框 + iframe > 打开子页面 > 数据传输/关闭模态框

    父页面bootstrap模态框: <div class="modal fade" id="myModal" tabindex="-1" ...

  8. bootstrap模态框modal使用remote第二次加载显示相同内容解决办法

    bootstrap模态框modal使用remote动态加载内容,第二次加载显示相同内容解决办法 bootstrap的modal中,使用remote可以动态加载页面到modal-body中,并弹窗显示 ...

  9. BootStrap 模态框基本用法

    <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 模态框(Modal)插件方法</title ...

随机推荐

  1. 面试复习(C++)之直接选择排序

    #include <iostream> using namespace std; void Selection(int *a,int len) { ;i<len;i++) { int ...

  2. java mysql 日期类型

    mysql(版本:5.1.50)的时间日期类型如下: datetime 8bytes xxxx-xx-xx xx:xx:xx 1000-01-01 00:00:00到9999-12-31 23:59: ...

  3. learn python, ref, diveintopython 分类: python 2015-07-22 14:42 14人阅读 评论(0) 收藏

    for notes of learing python. // just ignore the ugly/wrong highlight for python code. ""&q ...

  4. XPath

    XPath即为XML路径语言,它是一种用来确定XML(标准通用标记语言的子集)文档中某部分位置的语言.XPath基于XML的树状结构,提供在数据结构树中找寻节点的能力. XPath的需要理解的相关概念 ...

  5. Unity3D 一个较常见的错误信息“rect[2] == rt->GetGLWidth() && rect[3] == rt->GetGLHeight()”

    rect[2] == rt->GetGLWidth() && rect[3] == rt->GetGLHeight() 这个错误信息的具体含义我还不太清楚.它出现以后会不停 ...

  6. jpa遇到的 org.hibernate.PersistentObjectException: detached entity passed to persist异常

    jpa遇到的 org.hibernate.PersistentObjectException: detached entity passed to persist异常 发生这个原因是因为我们已经在实体 ...

  7. sqlite的常用语法

    sqllite 增删改查创建表的语法 创建表db.execSQL("create table user(_id integer primary key autoincrement,numbe ...

  8. Object.notifyAll()

    void java.lang.Object.notifyAll() Causes all threads which are waiting on this object's monitor (by ...

  9. HTML 行内元素和块级元素的理解及其相互转换

    块级元素:div, p(段落), form(表单), ul(无序列表), li(列表项), ol(有序列表), dl(定义列表), hr(水平分割线), menu(菜单列表), table(表格).. ...

  10. nodejs最新教程

    脚本模式 以下是我们的第一个Node.js程序: 实例 console.log("Hello World"); 保存该文件,文件名为 helloworld.js, 并通过 node ...