2013-03-12 57 views
0

我有一個擴展母版頁的aspx頁面。我想改變aspx頁面的文檔模式。我想把這一行放到aspx頁面。但它不允許。我不想把這段代碼放在網頁的頭部,只想改變頁面的文檔模式。有人能幫助我嗎?頁面文檔模式

<meta http-equiv="X-UA-Compatible" content="IE=9" /> 

回答

3

你需要在你的母版的佔位符:

<head> 
    <asp:ContentPlaceHolder id="plhHead" runat="server"/> 
</head> 

如果您<html/>標籤沒有runat="server",你需要把它應用到<head/>標籤就像KPL一樣。 然後填寫它在客戶端頁面就像你做你的主要內容佔位符:

<asp:Content ContentPlaceHolderId="plhHead" runat="server"> 
    <meta http-equiv="X-UA-Compatible" content="IE=9" /> 
</asp:Content> 
1

放置一個的ContentPlaceHolder在母版頁頭部分:

<head runat="server"> 
    <asp:ContentPlaceHolder ID="HeadContent" runat="server"> 
    </asp:ContentPlaceHolder> 
</head> 
.aspx

現在,

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> 
    <meta http-equiv="X-UA-Compatible" content="IE=9" /> 
</asp:Content> 
1

作爲替代在馬斯放置ContentPlaceHolder:你可以在頭部分添加自定義的內容您可以這樣做:

// Programmatically add a <meta> element to the Header 
HtmlMeta keywords = new HtmlMeta(); 
keywords.Name = "X-UA-Compatible"; 
keywords.Content = "IE=9"; 

Page.Header.Controls.Add(keywords);