0

I am trying to put many forms in a single master page in my asp.net application.I tried using panels with "runat=server" but its seems user input is not reaching server side.

Master page

<body>
    <form id="form1" runat="server">
    <asp:Panel ID="pnlLogin" runat="server">
     <form>
    <asp:Label ID="Msg" runat="server"></asp:Label>
      <asp:Button ID="btnLogSubmit" runat="server" CssClass="btn btn-primary"  OnClick="Login_Click" Text="Sign In" />
     </form>
    </asp:Panel>

    <asp:Panel ID="pnlRrg" runat="server">
     <form>
    <!--  Other form here -->
     </form>
    </asp:Panel>
    </form>
</body>

Code behind

 Protected Sub Login_Click(ByVal sender As Object, ByVal e As EventArgs)
        Msg.Text = "Serverside works"
    End Sub
user2650277
  • 6,289
  • 17
  • 63
  • 132
  • 1
    Multiple forms in ASP.NET is almost always a bad idea - system is designed to work with only one form for the whole page. What is your use case? Perhaps it can be achieve without many forms? – Andrei Oct 16 '15 at 16:36
  • Looks like you're missing a closing tag for form. – Joe M Oct 16 '15 at 16:36
  • @Andrei i have converted a theme from html to asp.net.There are many forms on a single page in this theme. – user2650277 Oct 16 '15 at 16:41
  • @JoeM its just a typo.Ty for notifying me – user2650277 Oct 16 '15 at 16:41
  • 1
    Then you should consider refactoring the theme to use one form. Possible suggestion: convert all forms to divs with other attributes (classes, ids) the same to not break the theme, and then wrap it in form. Or even get rid of forms all together, they all seem to be dumb like `
    `
    – Andrei Oct 16 '15 at 16:43
  • @Andrei is there a way to make it work with panels.refactoring will take too much time – user2650277 Oct 16 '15 at 16:45
  • 1
    Again, multiple forms on the page are not supported officially. There are [hacks](http://stackoverflow.com/q/7544454/728795) though, but think twice before going down that way, as there is no guarantee they behave stable. – Andrei Oct 16 '15 at 16:53

0 Answers0