在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>
相关推荐
[email protected]36 分钟前
ASP.NET Core SignalR - 部分客户端消息发送
后端·asp.net·.netcore
邪恶的贝利亚3 小时前
从webrtc到janus简介
后端·asp.net·webrtc
不超限15 小时前
Asp.net core 使用EntityFrame Work
后端·asp.net
不超限18 小时前
Asp.net Core 通过依赖注入的方式获取用户
后端·asp.net
新知图书1 天前
下载和安装Visual Studio(开发ASP.NET MVC应用)
ide·asp.net·visual studio
面朝大海,春不暖,花不开2 天前
Spring Boot MVC自动配置与Web应用开发详解
前端·spring boot·mvc
QQ_hoverer2 天前
前端使用 preview 插件预览docx文件
前端·javascript·layui·jquery
vvilkim3 天前
ASP.NET Core 中间件深度解析:构建灵活高效的请求处理管道
后端·中间件·asp.net
不超限3 天前
Asp.Net Core基于StackExchange Redis 缓存
redis·缓存·asp.net
残*影4 天前
什么是MVC?
java·spring·mvc