日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用ASP.net 2.0 的一些新特性

發布時間:2023/12/20 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用ASP.net 2.0 的一些新特性 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?by:(fallseir.lee) 飛揚輕狂


使用masterpage

新建一個site
添加一個新的masterpagethe_one.master
打開 the_one.master
添加 默認titlemeta
添加 全局控件 sitemap
添加 ContentPlaceHolder <?xml:namespace prefix = o />

<%@ Master Language="C#" AutoEventWireup="true"

?CodeFile="The_One.master.cs" Inherits="The_One_Master" %>

<!DOCTYPE html PUBLIC "-//W<?xml:namespace prefix = st1 />3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

??? <title>FeedSky</title>

??? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />??

???

</head>

<body>

??? <form id="form_one" runat="server">

??? <div>

??????? <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em"

??????????? PathSeparator=">" PathDirection="RootToCurrent" SiteMapProvider="XmlSiteMapProvider" SkipLinkText="<%$ Resources:SiteMap_LinkText %>" meta:resourcekey="SiteMapPath1Resource1">

??????????? <PathSeparatorStyle Font-Bold="True" ForeColor="#507CD1" />

??????????? <CurrentNodeStyle ForeColor="#FF8000" />

??????????? <NodeStyle Font-Bold="True" ForeColor="#507CD1" />

??????????? <RootNodeStyle Font-Bold="True" ForeColor="#284E98" />

????????? </asp:SiteMapPath>

??????? <asp:ContentPlaceHolder ID="Content_Header" runat="server">?????????

??????? </asp:ContentPlaceHolder>

??????? <asp:contentplaceholder id="Content_Main" runat="server">

??????? </asp:contentplaceholder>

??????? <asp:ContentPlaceHolder ID="Content_Footer" runat="server"></asp:ContentPlaceHolder>

??? </div>

??? </form>

</body>

</html>?


添加額外的頭信息


在頁面中使用

HtmlGenericControl c=new System.Web.UI.HtmlControls.HtmlGenericControl("meta");

??? c.Attributes["name"]="keywords";

??? c.Attributes["content"]="feedsky";

??? Master.Page.Header.AddParsedSubObject(c);


方式加入

創建測試頁
新建 aspx頁面 并選擇使用marsterpage

<%@ Page Language="C#" MasterPageFile="~/Templates/The_One.master"

AutoEventWireup="true" CodeFile="thetwo.aspx.cs"

Inherits="thetwo" Title="Untitled Page" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content_Header" Runat="Server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Content_Main" Runat="Server">

?

<asp:Label ID="Label1" runat="server" meta:resourcekey="Label1Resource1" Text="Label"></asp:Label><asp:Button

? ID="Button1" runat="server" meta:resourcekey="Button1Resource1" OnClick="Button1_Click"

? Text="Button" /><br />

? <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Global,Content2_content %>"></asp:Literal></asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Content_Footer" Runat="Server">

</asp:Content>


設置 sitemap

添加 sitemap

<?xml version="1.0" encoding="utf-8" ?>

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"

?????????????????????????? ?enableLocalization="true">

??? <siteMapNode url="~/Default.aspx" title="$Resources:global,FeedSky.com"? description="Feedsky.com's home page">

??????? <siteMapNode url="~/theone.aspx" title="$Resources:global,one"? description="1" />

??????? <siteMapNode url="~/thetwo.aspx" title="$Resources:global,two"? description="2" />

??? </siteMapNode>

</siteMap>


設置 web.config 關聯 sitemap

?

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">

??????????????????? <providers>

?????????????????????????? <add name="XmlSiteMapProvider" description="SiteMap provider which reads in .sitemap XML files."

????????????????????????????????? type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

????????????????????????????????? siteMapFile="feedsky.sitemap" securityTrimmingEnabled="true"/>

??????????????????? </providers>

????????????? </siteMap>


添加局部資源文件支持


打開 thetwo.aspx
選擇tools/Generate Local Resource
vs
將在thetwo.aspx所在的目錄下創建App_LocalResources文件夾 并生成the_two.aspx.resx文件
vs
會修改thetwo.aspx文件 加入meta:resourcekey="xxxx" the_two.aspx.resx文件中的字段對應

copy .resx
文件 the_two.aspx.en-us.resx 并修改里面的字段為英文 (添加頁面的英文支持)
asp.net2
會在用戶瀏覽時自動根據用戶瀏覽器的首選語言進行匹配

添加全局資源文件支持


新建 資源文件 global.resx
添加字段Content2_content 并設置其值為 測試
copy global.resx
global.en-us.resx
修改 Content2_content 的值為 test
the_two.aspx中添加

<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:Global,Content2_content %>"></asp:Literal>


以測試全局資源是否可用

$ Resources:Global,Content2_content

$Resources
為獲取資源文件中的內容

Global
為資源文件名,Content2_content為使用的鍵值

sitemap 中使用本地化資源

添加 enableLocalization="true"

設置文本獲取方式為"$Resources:global,one"

使用theme

添加skin文件 the_one
the_one.skin文件的文件夾用添加css文件


設置web.config


加入 <pages theme="the_one" styleSheetTheme="the_one"/>
asp.net 2.0
會自動加載 App_Themes/the_one下的.css文件 the_one.skin

轉載于:https://www.cnblogs.com/net66/archive/2005/11/13/275192.html

總結

以上是生活随笔為你收集整理的使用ASP.net 2.0 的一些新特性的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。