Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add meta tag to a content place holder page in asp.net?

I want to force IE mode to 7 while rendering in IE 11 browser. Able to do so by putting under the head tag for a separate aspx page. But I want to do so for a single content place holder page.

<pre lang="HTML">&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=7&quot; /&gt;</pre>

What I have tried:

Able to do so by putting under the head tag for a separate aspx page. But I want to do so for a single content place holder page.

<pre lang="HTML">&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=7&quot; /&gt;</pre>
Posted
Updated 9-Jun-16 10:03am
v3
Comments
John C Rayan 9-Jun-16 10:34am    
You mean to use it in Master Page ? Can you explain a bit more?
jgakenhe 9-Jun-16 12:16pm    
I would use an HTML condition statement. It might work!

https://www.sitepoint.com/web-foundations/internet-explorer-conditional-comments/

<!--[if IE 11 ]>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<![endif]-->

1 solution

If you want to add custom tags to the page header from a content page, you just need to add another ContentPlaceholder in the correct position:

Master page:
<%@ Master Language="C#" %>
<!doctype html>
<html>
<head runat="server">
    ...
    <asp:ContentPlaceholder id="HeaderContent" runat="server" />
    ...
</head>
<body>
    ...
    <asp:ContentPlaceholder id="MainContent" runat="server" />
    ...
</body>
</html>

Content page:
<%@ Page Language="C#" MasterPageFile="~/YourMasterPage.master" %>

<asp:Content runat="server" ContentPlaceholderID="HeaderContent">
    Extra headers here...
</asp:Content>

<asp:Content runat="server" ContentPlaceholderID="MainContent">
    Page content here...
</asp:Content>


However, there's no need to do that in this case. Any <meta http-equiv... tag is a substitute for a response header. All you really need to do is add the header from the code-behind of your content page:
C#
public partial class YourPage : Page
{
    public void Page_Load(object sender, EventArgs e)
    {
        Response.AppendHeader("X-UA-Compatible", "IE=7");
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900