本文介绍了如何在页面加载时动态更改aspx页面的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组ASPX页面,其中每个页面都有不同的标题,但是我想为没有标题的页面设置默认标题.默认标题必须是可配置的.
I had set of ASPX pages in which each page had different titles, but I want to put default title for pages which don't have a title. The default title must be configurable.
推荐答案
如果这是经典的ASP.NET(不是MVC),并且您正在使用MasterPage
,则可以在MasterPage
中的Page_Load
事件中设置默认标题. :
If this is classic ASP.NET (not MVC) and you are using MasterPage
then you can set default title in Page_Load
event in MasterPage
:
protected void Page_Load(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Page.Title))
{
Page.Title = ConfigurationManager.AppSettings["DefaultTitle"]; //title saved in web.config
}
}
这篇关于如何在页面加载时动态更改aspx页面的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!