惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog
腾讯CDC
L
LangChain Blog
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
量子位
Apple Machine Learning Research
Apple Machine Learning Research
Cloudbric
Cloudbric
B
Blog RSS Feed
B
Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
S
Schneier on Security
Project Zero
Project Zero
宝玉的分享
宝玉的分享
美团技术团队
MyScale Blog
MyScale Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
T
Threatpost
A
Arctic Wolf
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
爱范儿
爱范儿
Recorded Future
Recorded Future
C
CERT Recently Published Vulnerability Notes
T
Threat Research - Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
SecWiki News
SecWiki News
H
Hacker News: Front Page
AWS News Blog
AWS News Blog
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
C
Check Point Blog
L
Lohrmann on Cybersecurity
F
Full Disclosure
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
The Last Watchdog
The Last Watchdog
Martin Fowler
Martin Fowler

博客园 - Francis Liang

Windows Azure存储容器私有,公共容器,公共Blob的区别 关于Windows Azure 地缘组(Affinity Groups) 使用Windows Azure创建和发布ASP.NET应用程序 创建并使用Windows Azure虚拟机模板 Windows Azure 设置虚拟机静态外网IP地址 Windows Azure 配置多个站点的虚拟网络连接 Windows Azure 虚拟网络配置(Site to Site) Windows Azure 虚拟网络配置(Point to Site) Microsoft Azure云计算第一步—试用帐户申请 拥抱云计算 《Microsoft Office SharePoint Server 2007 Best Practices》书评 修改MOSS2007内容查询部件实现自定义格式显示 [.NET Active Directory开发]根据NativeGuid获取DirectoryEntry实例 IISRESET命令功能新发现 Biztalk Server 2006安装配置 Web开发中对元素样式使用过滤器以增强其可视化效果 使用DIME协议上传文件 使用证书来做RSA非对称式加密 使用MSAgent代替传统的MessageBox提示来增用客户端用户体验
动态改变ASP.net页面标题和动态指定页面样式表
Francis Liang · 2006-02-22 · via 博客园 - Francis Liang

         如果需要让asp.net应用程序对用户留有一定有自定义空间,例如用户要对页面使用自己定义的样式表或标题,可以使用下面的方法来动态指定:
首先对ASPX文件中<HEAD>中的页面标题和样式表进行修改
Visual Studio 生成的代码:
    <title>WebForm1</Title>
    <LINK ref="stylesheet" type="text/css" href="control.css">
修改后的代码:
    <title runat="server" id="Title1">WebForm1</title>
    <LINK id="link1" runat="server" type=text/css" ref="stylesheet"></link>
我们将这两个HTML元素都加上runat=server,标记为服务器端控件以使我们能在服务器代码对其进行访问。

在WebForm1.aspx.cs文件,我们就可以使用C#代码来对其将行控制
private void Button1_Click(object sender,System.EventArgs e)
{
        Control ctrl=Page.FindControl("Title1");  //寻找我们刚才修改为runat=server的那个Title
        ((HtmlGenericControl)ctrl).InnerText="Hello";
        ctrl=Page.FindControl("link1");
         ((HtmlGenericControl)ctrl).Attributes.Add("href","control.css");

}

通过以上步骤即可实现动态改变ASP.net页面标题和动态指定页面样式表