首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

在2005无法解决的有关问题

2012-01-16 
在2005无法解决的问题!我想在母板页里面headrunat server metaname description content %D

在2005无法解决的问题!
我想在母板页里面
<head   runat= "server ">
<meta   name= "description "   content= " <%=Description   %> "   />
<meta   name= "keywords "   content= " <%=Keywords   %> "   />
</head>
其中Description和Keywords是定义的两个属性

运行后看代码上面的内容变成
<head   runat= "server ">
<meta   name= "description "   content= "&lt;%=Description   %> "   />
<meta   name= "keywords "   content= "&lt;%=Keywords   %> "   />
</head>

如果把content=的 "去了的话
<head   runat= "server ">
<meta   name= "description "   content= <%=Description   %>   />
<meta   name= "keywords "   content= <%=Keywords   %>   />
</head>
运行包错:控件包含代码块(即   <%   ...   %> ),因此无法修改控件集合。

已经一天了还没解决,各位兄弟帮帮忙呀!

[解决办法]
哪就用我第2个方法啊:


如果要用runat= "server ",就在 <head> 加个asp:literal控件,然后后台设置控件的text属性来设置description和keywords

see:
-----------------------
<head runat= "server ">
<asp:literal id= "ltKeywords " runat= "server "> </asp:literal>
</head>

.cs
ltKeywords.text = " <meta name=\ "keywords\ " content=\ "关键词\ " /> ";

热点排行