如何将jQuery UI代码添加到ASP.NET Web窗体页面?

克莱·香农

在ASP.NET Web窗体项目中选择“新建”>“ Web窗体”时,您将获得一个包含以下代码的页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DuckbilledPlatypus.aspx.cs" 
Inherits="DuckbilledPlatypus" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

毫无疑问,添加jQuery代码的方式与典型方式相同(例如,在Razor / Web Pages应用程序/站点中),即引用必要的jQuery和jQueryUI * .js和* .css文件,然后将jQuery添加到脚本中元件。

但是,提供的表单/页面(“关于”和“联系”)具有以下代码:

<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" 
CodeFile="About.aspx.cs" Inherits="About" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: Title %>.</h2>
    <h3>Your application description page.</h3>
    <p>Use this area to provide additional information.</p>
</asp:Content>

jQuery / jQueryUI代码如何添加到此类代码中?可以将* .js和* .css引用以及脚本部分添加到asp:Content封装中吗?

谦卑的

这就是我的方法

<script src="Scripts/jquery-ui-1.10.3.min.js"></script>
<script src="Plugins/jquery.cookie.js"></script>
<link href="Content/themes/Smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<script>
    /**
      *This script creates a cookie that expires every 7 days. If you don't have this cookie
      *then the popup shows. If the cookie isn't expired, the popup doesn't show. 
     **/
    $(document).ready(function () {
        if ($.cookie('modal_shown') == null) {
            $.cookie('modal_shown', 'yes', { expires: 7, path: '/' });
            $('#popup').dialog({
                modal: true,
                buttons: {
                    Ok: function () {
                        $(this).dialog("close");
                    }
                }
            });
        }
    });
</script>
<div id="popup" style="display: none" title="New Release!">
    <span class="ui-icon-alert" style="float: left; margin: 0 7px 50px 0;"></span>
    <p><b>Issues Resolved</b></p>
    <ul>
        <li>New thing 1</li>
        <li>New thing 2</li>
        <li>New thing 3</li>
    </ul>
</div>
<h2><%: Title %>.</h2>
<h3>Your application description page.</h3>
<p>Use this area to provide additional information.</p>

这是使用母版页的页面。

对于不使用母版页的Web窗体,您将这样做。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DuckbilledPlatypus.aspx.cs" 
Inherits="DuckbilledPlatypus" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="Scripts/jquery-2.0.2.min.js"></script>
    <script src="Scripts/jquery-ui-1.10.3.min.js"></script>
    <script src="Plugins/jquery.cookie.js"></script>
    <link href="Content/themes/Smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
    <script>
        /**
          *This script creates a cookie that expires every 7 days. If you don't have this cookie
          *then the popup shows. If the cookie isn't expired, the popup doesn't show. 
         **/
        $(document).ready(function () {
            if ($.cookie('modal_shown') == null) {
                $.cookie('modal_shown', 'yes', { expires: 7, path: '/' });
                $('#popup').dialog({
                    modal: true,
                    buttons: {
                        Ok: function () {
                            $(this).dialog("close");
                        }
                    }
                });
            }
        });
    </script>
    <div id="popup" style="display: none" title="New Release!">
        <span class="ui-icon-alert" style="float: left; margin: 0 7px 50px 0;"></span>
        <p><b>Issues Resolved</b></p>
        <ul>
            <li>New thing 1</li>
            <li>New thing 2</li>
            <li>New thing 3</li>
        </ul>
    </div>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

如您所知,您只需将其放在标记中。我希望这有帮助!

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何将jQuery添加到asp.net页面并格式化GridView列

来自分类Dev

如何将jQuery代码添加到HTML页面

来自分类Dev

将角色列添加到ASP.NET Web窗体中的DataGrid

来自分类Dev

如何将网站图标和页面标题添加到 asp.net 页面

来自分类Dev

将ASP.NET MVC区域添加到ASP.NET Web窗体现有项目

来自分类Dev

如何将datagrid添加到ASP.net Web应用程序?

来自分类Dev

在ASP.NET Web窗体中,如何使用“获取”请求调用页面方法

来自分类Dev

如何从ASP.NET Web窗体应用程序生成静态HTML页面

来自分类Dev

将Web API添加到现有的asp.net Web窗体应用程序

来自分类Dev

将Web API添加到现有ASP.NET Web窗体应用程序时出现问题

来自分类Dev

ASP.Net MVC:如何将国家/地区代码添加到所有url

来自分类Dev

如何将具有动态内容的捆绑软件添加到ASP.NET Web优化中

来自分类Dev

将ASP代码添加到DNN页面?

来自分类Dev

将共享身份验证添加到Classic ASP.NET Web窗体应用程序和Web API应用程序

来自分类Dev

如何将Web服务引用添加到类库项目.NET 4.0中

来自分类Dev

如何将CSS和JavaScript添加到Windows窗体应用程序C#.net

来自分类Dev

如何将ASP.Net页面链接到代码?

来自分类常见问题

如何将Web API添加到现有的ASP.NET MVC(5)Web应用程序项目中?

来自分类Dev

将jQuery验证添加到ASP.NET MVC页面中发布的“选定”下拉列表中

来自分类Dev

如何在ASP.Net中将Web服务层添加到Web应用程序

来自分类Dev

将Web服务添加到现有的ASP .NET MVC 3站点

来自分类Dev

将Swagger添加到ASP.Net Core Web API

来自分类Dev

将web.config文件添加到Asp.Net Core项目

来自分类Dev

将Web服务(ASMX)添加到现有的asp.net表单网站

来自分类Dev

以asp.net Web形式将文本从文本框添加到列表框

来自分类Dev

如何在asp.net mvc 5中使用jQuery ajax将模型添加到剃须刀页面?

来自分类Dev

ASP.Net Ajax页面方法和自定义http错误(Web窗体)

来自分类Dev

如何将项目从数据表添加到asp.net中的列表

来自分类Dev

如何将标签添加到Asp.net文本框中?

Related 相关文章

  1. 1

    如何将jQuery添加到asp.net页面并格式化GridView列

  2. 2

    如何将jQuery代码添加到HTML页面

  3. 3

    将角色列添加到ASP.NET Web窗体中的DataGrid

  4. 4

    如何将网站图标和页面标题添加到 asp.net 页面

  5. 5

    将ASP.NET MVC区域添加到ASP.NET Web窗体现有项目

  6. 6

    如何将datagrid添加到ASP.net Web应用程序?

  7. 7

    在ASP.NET Web窗体中,如何使用“获取”请求调用页面方法

  8. 8

    如何从ASP.NET Web窗体应用程序生成静态HTML页面

  9. 9

    将Web API添加到现有的asp.net Web窗体应用程序

  10. 10

    将Web API添加到现有ASP.NET Web窗体应用程序时出现问题

  11. 11

    ASP.Net MVC:如何将国家/地区代码添加到所有url

  12. 12

    如何将具有动态内容的捆绑软件添加到ASP.NET Web优化中

  13. 13

    将ASP代码添加到DNN页面?

  14. 14

    将共享身份验证添加到Classic ASP.NET Web窗体应用程序和Web API应用程序

  15. 15

    如何将Web服务引用添加到类库项目.NET 4.0中

  16. 16

    如何将CSS和JavaScript添加到Windows窗体应用程序C#.net

  17. 17

    如何将ASP.Net页面链接到代码?

  18. 18

    如何将Web API添加到现有的ASP.NET MVC(5)Web应用程序项目中?

  19. 19

    将jQuery验证添加到ASP.NET MVC页面中发布的“选定”下拉列表中

  20. 20

    如何在ASP.Net中将Web服务层添加到Web应用程序

  21. 21

    将Web服务添加到现有的ASP .NET MVC 3站点

  22. 22

    将Swagger添加到ASP.Net Core Web API

  23. 23

    将web.config文件添加到Asp.Net Core项目

  24. 24

    将Web服务(ASMX)添加到现有的asp.net表单网站

  25. 25

    以asp.net Web形式将文本从文本框添加到列表框

  26. 26

    如何在asp.net mvc 5中使用jQuery ajax将模型添加到剃须刀页面?

  27. 27

    ASP.Net Ajax页面方法和自定义http错误(Web窗体)

  28. 28

    如何将项目从数据表添加到asp.net中的列表

  29. 29

    如何将标签添加到Asp.net文本框中?

热门标签

归档