views:

9

answers:

0

First off, I am running my website in IE7 Compatability mode with the following code.

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

I have a web page that has a gridview with a link button in it. When I click the link button a new page opens in a seperate window(or tab). However once I do this, the original page is no longer running in IE7 compatability mode.(you can see the compatability button next to the address bar which you cannot see when the page is programatically placed in compatability mode)

Why?

THE RE-CREATION: (you must have ie8 to do this recreation) I have grossly simplified my situation to show you the simplest situation where this problem occurs.

Step 1: Create a new website in VS

Step 2: Code the following code into Default.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        List<TestObject> data = new List<TestObject>();
        TestObject row = new TestObject();
        row.number = "1";
        row.link = "click me";
        data.Add(row);
        GridView1.DataSource = data;
        GridView1.DataBind();
    }

    protected void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
    {

        object test2 = sender;
        GridView grid = (GridView)test2;

        if (e.CommandName == "link")
        {
            Response.Write("<script type='text/javascript'>window.open('Default.aspx');</script>");
        }

    }


    private class TestObject
    {
        public string number {get; set;}
        public string link { get; set; }


    }

}

Step 3: Copy the following code into Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" onrowcommand = "GridView1_RowCommand" >
            <Columns>
                <asp:BoundField HeaderText="number" DataField="number"/>
                <asp:TemplateField HeaderText = "Link Test" >
                    <EditItemTemplate>
                        <asp:Label ID="TextBox1" runat="server" Text = '<%#Eval("link") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="Label3" runat="server" Text = '<%#Eval("link") %>' 
                        CommandName = "link"
                        CommandArgument = '<%# Eval("link") %>' > </asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

    </div>
    </form>
</body>
</html>

Step 4: Run it

Step 5: Click the link button

You will notice that before you click the link button the compatability button usually located to the right of the address bar does not exsist(as is the expected behavior). Notice after you click the link button the compatability button apears(unexpected behavior).

Any ideas?

Thanks!!!