如何实现所有页面的TITLE统一?

BigBlue 2004-06-21 02:12:10
例如我有20个页面,每个页面的TITLE相同,这时我如果想修改一下,需要修改20次,怎么才能定义一个常量来控制,这样只要改一个地方就OK了。

在ASP里会用,。NET里有些问题,请指教!
...全文
236 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tavor 2004-06-21
  • 打赏
  • 举报
回复
of course, you can save it in the web.config file or set it a const property in a public class.
then you bind the title like this:
use the property:
public class Config
{
public Config()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static string pagetitle="test";
public static string Title
{
get
{
return pagetitle;
}
}
}
in a aspx file:
<title>
<%= MyTest.Config.Title %>
</title>

if set the title in the web.config file, then you can get it use like below:
in aspx file:
<title>
<%= System.Configuration.ConfigurationSettings.AppSettings["siteTitle"] %>
</title>
in web.config file the appSettings sections add as below:

<add key="siteTitle" value="my site"/></appSettings>


other is ok!
lemong 2004-06-21
  • 打赏
  • 举报
回复
<%= System.Configuration.ConfigurationSettings.AppSettings["Title"]%>

修改web.config,增加如下语句:

<appSettings>
<add key="Title" value="统一的title测试"/>
</appSettings>
BigBlue 2004-06-21
  • 打赏
  • 举报
回复
我想要这种效果
定义:
countname =‘名称’;

使用:
<title><%=countname%></title>
chieftech 2004-06-21
  • 打赏
  • 举报
回复
用框架,给分吧
brargil 2004-06-21
  • 打赏
  • 举报
回复
使用FRAME内嵌你所有的页面啊

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧