C# 是否可以从代码隐藏中编辑元描述?
在VisualStudio2005网站的母版页中,我使用元描述作为C# 是否可以从代码隐藏中编辑元描述?,c#,asp.net,html,C#,Asp.net,Html,在VisualStudio2005网站的母版页中,我使用元描述作为 <meta name="keywords" content="coupons, coupons, online coupons, health deals, health coupons, computer coupons, bargains, hot bargains" /> <meta name="description" content="<%=MyMetaDescription%>" /&g
<meta name="keywords" content="coupons, coupons, online coupons, health deals, health coupons, computer coupons, bargains, hot bargains" />
<meta name="description" content="<%=MyMetaDescription%>" />
我想替换每个aspx页面中的内容。我如何使用它?
虽然我试图替换代码隐藏页面中的内容,但我得到了与描述相同的内容
在代码隐藏中,我调用了Master.MyMetaDescription=“”
有人能帮我解决这个问题吗。提前多谢 在
部分中的
标记处创建一个内容占位符:
<html>
<head>
<asp:ContentPlaceHolder ID = "MetaContent" runat = "server" />
</head>
<!-- other content -->
</html>
在页面中,您可以使用不同的
标记替换内容
<asp:Content ID = "MyMeta" PlaceHolderID = "MetaContent" runat = "server">
<meta />
</asp:Content>
在
部分的
标记所在位置制作一个内容占位符:
<html>
<head>
<asp:ContentPlaceHolder ID = "MetaContent" runat = "server" />
</head>
<!-- other content -->
</html>
在页面中,您可以使用不同的
标记替换内容
<asp:Content ID = "MyMeta" PlaceHolderID = "MetaContent" runat = "server">
<meta />
</asp:Content>
恶心已经提供了一种添加元内容的简单方法
不管怎样,请查看如何从代码隐藏添加元标记。基于此,它还提供了一个很好的解决方案,可以轻松地将元标记添加到页面。恶心已经提供了一种添加元内容的简单方法 不管怎样,请查看如何从代码隐藏添加元标记。基于此,它还提供了一个很好的解决方案,可以轻松地向页面添加元标记。我将使用以下方法:
this.Page.MetaKeywords = "football, sport, golf";
this.Page.MetaDescription = "My site is all about football and golf";
显然,如果您只想附加到它们,那么只需使用+=
(不要忘记关键字的前导)。我会使用以下方法:
this.Page.MetaKeywords = "football, sport, golf";
this.Page.MetaDescription = "My site is all about football and golf";
显然,如果您只想附加到它们,那么只需使用
+=
(不要忘记关键字的前导)。您在哪里设置MyMetaKeyWords的值?你能发布那个代码吗?那是MyMetadescription,我编辑的。我在code behind中使用Master.MyMetadescription来编辑它,但它不起作用。顺便说一句,这可能对你没有多大帮助:搜索引擎现在大多忽略了这些东西……你在哪里设置MyMetaKeyWords的值?你能发布那个代码吗?那是MyMetadescription,我编辑的。我在code behind中使用Master.MyMetadescription来编辑它,但它不起作用。顺便说一句,这可能对你没有多大帮助:搜索引擎现在大多忽略了这些东西。。。