无法在 asp.net 中设置页面的标题属性
我在 ASP.NET 中遇到一个奇怪的问题。
我有一个页面,在某些情况下无法设置 Title
属性。 如果我将 Title
属性设置为 Page_PreLoad 中的字符串值,则该值为空。然而,这种情况仅在某些情况下发生,我不明白什么时候真正发生。
如果我设置断点并使用调试器查看,则在设置 Title="test";
后,Title 属性为空。然而浏览器中的PageTitle显示“test”。如果我在页面标记中使用标题属性,它是空的。标题属性是否有一些我必须知道的特殊魔法?
I have a weird problem in asp.net.
I have a page in which I can't set the Title
-property under some circumstances.
If I set the Title
-property to a string-value in Page_PreLoad, then the value is empty. However this happens only in some circumstances, I don't understand really when.
If I set a breakpoint and look with the debugger, after setting Title="test";
, the Title property is empty. However the PageTitle in the browser shows "test". If I use the Title-property in the markup of the page, it is empty. Is there some special magic with the Title-property, I have to know about?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Page.Title 属性是 HtmlHead 控件的包装器,该控件通过 Page.Header 公开。在标头初始化之前,它将标题存储在属性中,直到它被初始化。每当标头建立时,它都会复制此属性...这可能就是问题所在,或者可能是其他问题...
HTH。
The Page.Title property is a wrapper around the HtmlHead control, which is exposed through Page.Header. Before the header gets initialized, it stores the title in a property until it gets initialized. Whenever the Header gets established, it copies this property over... That may be what the issue is, or maybe its something else...
HTH.