Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IE9正在复制母版页内容_C#_Asp.net_Internet Explorer 9 - Fatal编程技术网

C# IE9正在复制母版页内容

C# IE9正在复制母版页内容,c#,asp.net,internet-explorer-9,C#,Asp.net,Internet Explorer 9,创建全新的asp.net webforms项目。 添加母版页和使用该母版页的webforms页 母版页 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="AspWeird.Site1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/

创建全新的asp.net webforms项目。 添加母版页和使用该母版页的webforms页

母版页

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="AspWeird.Site1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div id="main_content_container">
            <div id="main_content_row">
                <div id="main_content_column">
                  <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
                </div>

                <div id="side_content_column">

                </div>
            </div>
        </div>

    </div>
    </form>
</body>
</html>
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AspWeird.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>Hello World</h2>

<div>
    <form></form>
</div>

</asp:Content>

这只发生在

<div><form></form></div>

在那里停下来。如果你移除它,一切都正常


通常,ASP.NET基于单个表单标记工作。唯一令人惊讶的是,你看到了自己的症状,而不是完全的错误。因此,您不应该尝试嵌套表单标记。从最低的主控页到最外层的派生页应该只有一个表单标记


更新

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="AspWeird.Site1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div id="main_content_container">
            <div id="main_content_row">
                <div id="main_content_column">
                  <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
                </div>

                <div id="side_content_column">

                </div>
            </div>
        </div>

    </div>
    </form>
</body>
</html>
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AspWeird.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>Hello World</h2>

<div>
    <form></form>
</div>

</asp:Content>

这看起来确实像IE9中的一个bug。如果您使用Fiddler查看通过网络发送的实际标记,则代码不会重复。

嵌套的表单标记会导致无效的HTML,而您在IE9中看到的呈现很可能就是这种结果。在开发人员工具中看到的DOM是呈现的,而不是作为HTTP响应接收的

我不知道这是否与问题有关,但我认为您不应该有嵌套的表单标记。我只有在asp.net项目的IE9中才会遇到同样的问题。真奇怪。当我注意到z-index复制了我的工具提示标记时,我正在尝试使用z-index。MVC中的多个
没有问题,尽管它们不应该嵌套。是的,我知道不要嵌套表单标记。由于webforms中的所有内容都嵌套在一个表单中,因此在我注意到这种行为的特定情况下,这是没有帮助的(不需要做很多工作)。我之所以发布这篇文章,是因为IE做了一些非常奇怪的事情,我想找出原因。@chrisortman-你的文章说这发生在IE9中。这是否意味着这种行为在其他浏览器(如FF或Chrome)中不会发生?@chrisortman-不过,一个有趣的问题是“如果标记无效,它应该怎么做?”TBH,我不确定。可能切换到怪癖模式?@chrisortman-如果您试图查看无效标记,则会破坏网站的查看方式。我希望它会尽可能地坏,这样我就知道如何修复它了。更好的是让VS捕捉到它并给我一个错误。破坏的形式是神奇地添加标记,这并不理想,但只要外观破坏到足以修复它,它就是这样。