在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>
相关推荐
鶴哥只手遮天19 小时前
jQuery 4.0 源码架构与工程实践-第 01 章 · 全景与工程结构:一个 20 岁库的自省
前端·javascript·jquery
java_nnnn1 天前
Spring MVC小案例(1)
java·后端·spring·mvc
captain3761 天前
Spring Web MVC(2)
java·前端·spring boot·后端·spring·mvc
鶴哥只手遮天2 天前
jQuery 4.0 源码架构与工程实践-第 10 章 尺寸、几何与显隐
前端·javascript·jquery
努力实干2 天前
第 4 课:MVC、MVP 与 MVVM 架构
架构·mvc
变与不变8063 天前
jQuery细节以及使用应用场景
前端·javascript·jquery
OxYGC3 天前
Spring 面经系列 · 第 6 篇:Spring MVC 请求全流程、父子容器与零配置原理
java·spring·mvc
小尹哥-程序员3 天前
第9集:Spring AI Advisor链:像Spring MVC拦截器一样优雅
人工智能·spring·mvc
步行cgn4 天前
Spring MVC 视图机制的核心接口与类
java·开发语言·后端·spring·mvc
鸠摩智首席音效师5 天前
如何清理 ASP.NET 临时文件 ?
后端·asp.net