开发者

HTML and ASP Button Conflict on IE

I got a problem using two types of button on IE. For this test i created a ASP.NET webpage in Visual Studio and a开发者_Python百科dded the code below inside Default.aspx

  <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <form action="#" method="post">
      <input type="submit" name="test" value="Test!" class="button" title="Subscribe" />
    </form>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    Hello <asp:Label ID="l1" runat="server" Text=""></asp:Label>
  </asp:Content>

The problem happens when i try to use the asp:button. It won´t work (no postback).


If you really need the form attribute you can close the form from the master page and then reopen it after the form your adding. Something like this:

  <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    </form>
    <form action="#" method="post">
      <input type="submit" name="test" value="Test!" class="button" title="Subscribe" />
    </form>
    <form action="#" method="post">
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    Hello <asp:Label ID="l1" runat="server" Text=""></asp:Label>
  </asp:Content>

But I agree with Justin, why do you need a form within a form.


Your master page will already have a form element that contains the content area, so the form in your markup above is essentially a nested form. That's probably what's messing you up; in fact, I don't even know if it's valid to do that. Either way, you don't need the form there unless it has some kind of purpose you're not mentioning. I'd suggest removing it and trying again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜