母版页:允许每个内容页具有不同的标题和关键字 [英] Master Pages: Allowing Each Content Page to Have Different Title and Keywords

查看:62
本文介绍了母版页:允许每个内容页具有不同的标题和关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我确定必须先问过这个问题,但是我无法找出如何克服在ASP.NET 4中使用母版页时似乎很明显的问题.

由于母版页包含< head/>文档的文档"部分,其中还包含标题和元数据(例如描述",关键字").由于此数据确实确实需要特定于每个页面,因此如何在每个页面上进行设置,而不是继承母版页文件中的值?

关于此的MSDN信息似乎没有提及此信息,但是我敢肯定,我读过某个地方,现在可以在ASP.NET 4中做到这一点.

有关相关信息的建议或指示将不胜感激.

帕特里克···
:〜

Hi,

I am certain this question must have been asked before, but I cannot find out how to overcome what appears to be an obvious problem when using master pages in ASP.NET 4.

Since the master page contains the <head/> section of the document, it also contains the title and meta data (e.g. ''description'', ''keywords''). Since this data really does need to be specific to each page, how do you set is on a per-page basis instead of inheriting the values in the master page file?

The MSDN information on this does not seem to mention this, but I am sure I read somewhere that this was now possible in ASP.NET 4.

Advice or pointers to relevant information would be very much appreciated.

Best wishes, Patrick

:~

推荐答案

在母版页中,您可以执行以下操作:


In the master page you can do this:


<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
</head>



然后在aspx中:



Then in the aspx:

<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleContent" runat="server">
    <asp:Literal ID="TitleLiteral" runat="server" Text="Whatever" />
</asp:Content>




我相信meta标签可以用类似的方式完成,但是您需要将整个标签放在文字的文本中.




I believe the meta tags can be done in a similar fashion, but you''ll need to put the whole tag in the text of the literal.


这篇关于母版页:允许每个内容页具有不同的标题和关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆