baros
baros

Reputation: 251

page document mode

I've an aspx page that extends a master page. I want to change aspx page's document mode. I'd like to put this line to aspx page. But It doesn't allow. I don't want to put this code to master page's head want only change the page's document mode. Can somebody help me?

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

Upvotes: 0

Views: 1098

Answers (3)

Linus Caldwell
Linus Caldwell

Reputation: 11058

You need a placeholder in your masterpage:

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

If your <html/> tag has no runat="server", you need to apply it to the <head/> tag like KPL did. And then fill it in the client page like you do with your main content placeholder:

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

Upvotes: 3

Shai Cohen
Shai Cohen

Reputation: 6249

As an alternative to placing a ContentPlaceHolder in the Master page, you can do this:

// 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);

Upvotes: 1

Kapil Khandelwal
Kapil Khandelwal

Reputation: 16144

Place a ContentPlaceHolder in the head section of your Master Page:

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

Now from your .aspx page, you can add custom content in the head section:

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

Upvotes: 1

Related Questions