在ASP.NET MVC中使用JQuery提供的弹出窗口(模态窗口)

在ASP.NET MVC中使用JQuery提供的弹出窗口(模态窗口)

原理

使用<div>图层灵活显示在浏览器的任何位置。默认情况下指定<div>不可见

引用

  • 样式表

在JQuery的官方网站可以下载对应的css样式表。打开官网的样例页

找到样式表引用路径

html 复制代码
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">

将其下载到本机,其中thme

比如,我的样式表路径为

html 复制代码
<link rel="stylesheet" href="~/lib/jquery/ui/1.11.3/themes/smoothness/jquery-ui.css">
  • JQuery库

下载JQuery和JQuery-ui库,并放置在对应的路径中

html 复制代码
<script src="~/lib/jquery/jquery-1.11.3/jquery-1.11.3.min.js"></script>
<script src="~/lib/jquery/ui/1.11.3/jquery-ui.min.js"></script>

注意:前后顺序

这里要注意,在ASP.NET模板中,_Layout.cshtml文件末尾会引用JQuery.js,将其删除,否则会出现重复引用导致错误

Javascript调用

加入div的定义

html 复制代码
<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>

加入javascript调用

javascript 复制代码
<script>
  $( function() {
    $( "#dialog" ).dialog();
  } );
</script>
相关推荐
辰海Coding2 小时前
MiniSpring框架学习-为什么一个请求访问 /helloworld,最后能调用到某个 Controller 方法?原始 MVC实现
java·学习·程序人生·spring·mvc
来恩10032 天前
jQuery选择器
前端·javascript·jquery
无风听海2 天前
深入理解 ASP.NET Core 中的 UseRouting 与 UseEndpoints
后端·asp.net
无风听海2 天前
ASP.NET Core Minimal API 深度解析
后端·asp.net
@菜菜_达3 天前
jquery.inputmask插件介绍
前端·javascript·jquery
步步为营DotNet3 天前
解锁.NET 11 新境:ASP.NET Core 10 在微服务安全通信的深化与实践
微服务·asp.net·.net
无风听海4 天前
深入理解 ASP.NET Core 中的 IActionResult
后端·asp.net
无风听海4 天前
ASP.NET Core Results<T1, T2>深度解析
后端·asp.net
大熊程序猿6 天前
ASP.NET Core 认证授权:JWT与OAuth2实战
后端·asp.net
那个失眠的夜6 天前
SpringBoot
java·开发语言·spring boot·spring·mvc·mybatis