事件仅在特定机器上触发,但不在其他机器上触发

发布于 2024-10-01 17:43:15 字数 1732 浏览 2 评论 0原文

几周来我一直在尝试解决这个问题,但它变得非常令人沮丧。基本上我有一个简单的项目,其中包括一个母版页和一个内容页。下面的代码是在内容页中找到的

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Button ID="Button1" runat="server" Text="ButtonContent" 
        onclick="Button1_Click" />
</asp:Content>

按钮绑定到一个简单的事件。设置断点来检测事件是否按预期触发。当表单放置在内容占位符上方时,不会触发该事件。

 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> 
<!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>
    <form></form>
    </div>

    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>

    <div>


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

但是,当表单被删除或放置在内容占位符下方时,会触发该事件。另一方面,在某些机器上,我发现如果将表单放置在内容占位符之前并不重要。我已经在 4 台机器(三台 Windows 7 和一台 XP)上尝试过这个项目,无论两台机器上的表单放置如何,它都可以工作,并且在另外两台机器上也受到表单放置的影响。

有人可以向我指出一些可以解决此问题的设置或提供任何建议来解决我的问题吗?我需要在内容占位符之前有一个表格,所以删除是不可能的。某种设置阻止项目在另一台机器上正常工作也是有道理的

I have been trying to solve this problem for several weeks now and it is getting really frustrating. Basically i have a simple project which includes one master page and one content page. the following code is what is found in the content page

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Button ID="Button1" runat="server" Text="ButtonContent" 
        onclick="Button1_Click" />
</asp:Content>

The button is bound to a simple event. A break point is set to detect whether the event fired as expected. The event does not fire when a form is placed above the content place holder.

 <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> 
<!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>
    <form></form>
    </div>

    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>

    <div>


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

however the event is fired when the form is removed or place below the content place holder. On the other hand, on some machines i have found that it does not matter if a form is placed before the content place holder. I have tried this project on 4 machines (three windows 7 and one xp) it has worked regardless of form placement on two machines and has been subject to form placement on the other two.

Could some one please point me to some setting which could solve this problem or offer any advice to solve my problem. I need a form before the content place holder so removing is out of the question. It would also make sense that some sort of setting is preventing the project from working correctly on another machine

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2024-10-08 17:43:15

根据 HTML 规范,表单中不能有表单。如果我没记错的话,当你有这种结构时,某些浏览器会崩溃。我认为IE运行良好。

如果您需要其他表单,请将其放在

之外
- 具体来说,在上面。这是有效的。

per HTML spec, you can not have form inside form. If I remember correctly some browsers break when you have this kind of structure. I think IE works fine.

If you need another form, put it outside of the <form id="form1" runat="server">
- above it, specifically. That is valid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文