如题,在beta版中的
this.Header.Metadata.Add("taye", "value");
不能用了。
this.Header.Metadata.Add("taye", "value");
不能用了。
解决方案 »
- 高分求助 时间比较的问题
- 定时生成静态页问题
- 为何radiobuttonlist没有SelectedValue一项?
- atlas和asp.net ajax是一回事吗?
- 有关循环中数组给值的问题(50)
- 在线等,一个日期格式的简单问题
- 请高手解决问题,否则新年被炒鱿鱼了 ! 555
- 哪位大哥帮我解决一下验证控件的问题!
- 在对产品的详细信息进行绑定时我改为以下,却出现了“ASP.prodetails_aspx.FrameworkInitialize()”: 没有找到适合的方法来重写
- Membership enablePasswordRetrieval属性和GetUser()的问题
- 强制类型转换?
- 如何求出一个decimal或double类型的数值的小数位数呢?
posted at Tuesday, August 17, 2004 3:32 AM by Anders Norås
The head element in the ASP.NET 2.0 page template is by default declared to run at the server. In addition the System.Web.UI.HtmlControls namespace has a new class called HtmlHead defined. When you set the id attribute of the head element to “Head” this becomes a member of your class (which inherits from System.Web.UI.Page).
The reason for you not seeing the code defining this member is that ASP.NET 2.0 uses partial classes to separate user defined code from tool generated code.
As a result of this you get a member naming conflict when defining an additional member called “Head” typed System.Web.UI.HtmlControls.HtmlGenericControl. To solve your problem using your existing code which I reckon is similar to this:
ASPX snippet:
<head id="Head" runat="server"> Codebehind snippet:
protected HtmlGenericControl Head;
private void Page_Load(object sender, System.EventArgs e)
{
HtmlGenericControl meta=new HtmlGenericControl("meta");
meta.Attributes.Add("name","pragma");
meta.Attributes.Add("content","no-cache");
Head.Controls.Add(meta);
} Remove the declaration of the “Head” member in the code behind file. Another option is to add your metadata using the Page.Header.Metadata collection like this:
Page.Header.Metadata.Add("name", "pragma");
Page.Header.Metadata.Add(“content”,”no-cache”):
=====================================================
调试后得到的结果如下:
<head><link href="../App_Themes/White/aboutMenu.css" type="text/css" rel="stylesheet" /><link href="../App_Themes/White/Default.css" type="text/css" rel="stylesheet" /><title>
Untitled Page
</title><meta name="robots" content="all" /><link rel="Shortcut Icon" href="../favicon.ico" /><meta name="pragm" content="no-cache"></meta><style type="text/css">
.ctl00_Menu2_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }
.ctl00_Menu2_1 { text-decoration:none; }
.ctl00_Menu2_2 { }</style></head>这个是正确的答案么?