multiple forms on single page?

Discussion in 'ASP .Net' started by Davids, Nov 10, 2004.

  1. Davids

    Davids Guest

    this was impossible to implement on old ASP, is it the same for .Net?
     
    Davids, Nov 10, 2004
    #1
    1. Advertisements

  2. Davids

    Jeff Dillon Guest

    Actually was not impossible on classic ASP.

    Jeff
     
    Jeff Dillon, Nov 10, 2004
    #2
    1. Advertisements

  3. Hi,

    In ASP multiple forms were no problem at all. In ASP.Net you can only have
    one form (Form1) for server controls. These will then be available to you
    with their values when you post back. You can also add all the other forms
    you want but they won't be as useable server-side. I believe you can still
    get your values but you need to go through the Request object rather than
    having an object that represents each control to work with. I may be wrong
    about that last point though so hopefully someone who knows for sure can
    talk about this. Good luck! Ken.
     
    Ken Dopierala Jr., Nov 10, 2004
    #3
  4. Davids

    Guest Guest

    You can only have 1 <form id="myForm" runat="server"> server control.
    However, you can still use plain ole html forms with action="some url"; but
    it cannot have a runat="server". Once you do this, you cannot have any
    asp.net server controls within this HTML form tag.

    There is a work-a-round comming is asp.net 2.0. Stay tuned!
     
    Guest, Nov 10, 2004
    #4
  5. Davids

    Ian Suttle Guest

    If you are simply referring to a matter of having the tags in the same
    page, but not needing to use them all at the same time, you can put
    them in panels. When the HTML is rendered, only 1 FORM tag should be
    visible (all panels with form tags but one should be hidden).

    Perhaps if you explain your intent we can provide a solution.
    Thanks,
    Ian Suttle
    http://www.IanSuttle.com
     
    Ian Suttle, Nov 10, 2004
    #5
  6. Davids

    Mark Rae Guest

    Er...no it wasn't...
     
    Mark Rae, Nov 10, 2004
    #6
  7. You can only have one visible server form on the page at a time.
    So you could have more than one server form as long as you only show one at
    a time.
    Or you can have more than one form visible on your page at a time, but only
    one of them can be a server form (i.e. with the runat=server attribute.)
    Server forms only support posting back to themselves (not to other pages.)

    This will all become more flexible in .NET version 2.
     
    Steve C. Orr [MVP, MCSD], Nov 11, 2004
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.