multiple forms in asp.net

Discussion in 'ASP .Net' started by Josh Harris, Jan 6, 2004.

  1. Josh Harris

    Josh Harris Guest

    I am using the IBuySpy portal in c#. The problem I am having is in
    nesting a second form within the page. The entire page is within one
    form (for the user controls). I want to have a form that allows users
    to search a phone list by entering a name, and clicking "submit".
    This is extremely easy to do with a simple html form. This is not the
    case with asp.net though, I cannot have an html form nested within the
    main form for the page. This means that I have to create a user
    control that has the form contained within it, make a post back to the
    server and then redirect the user to the search result page. This is
    a huge setback in my opinion, am I missing something? is there a
    better way to handle this?

    TIA
    -Josh
    Josh Harris, Jan 6, 2004
    #1
    1. Advertising

  2. First of all, you can never nest one HTML form inside another in any HTML
    document. Secondly, a WebForm Page can have one and only one runat=server
    form on it. It can have any number of regular HTML forms in it that live
    outside of the WebForm.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Josh Harris" <> wrote in message
    news:...
    > I am using the IBuySpy portal in c#. The problem I am having is in
    > nesting a second form within the page. The entire page is within one
    > form (for the user controls). I want to have a form that allows users
    > to search a phone list by entering a name, and clicking "submit".
    > This is extremely easy to do with a simple html form. This is not the
    > case with asp.net though, I cannot have an html form nested within the
    > main form for the page. This means that I have to create a user
    > control that has the form contained within it, make a post back to the
    > server and then redirect the user to the search result page. This is
    > a huge setback in my opinion, am I missing something? is there a
    > better way to handle this?
    >
    > TIA
    > -Josh
    Kevin Spencer, Jan 6, 2004
    #2
    1. Advertising

  3. 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.)

    It's my understanding that this will become more flexible in .NET version 2.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com



    "Josh Harris" <> wrote in message
    news:...
    > I am using the IBuySpy portal in c#. The problem I am having is in
    > nesting a second form within the page. The entire page is within one
    > form (for the user controls). I want to have a form that allows users
    > to search a phone list by entering a name, and clicking "submit".
    > This is extremely easy to do with a simple html form. This is not the
    > case with asp.net though, I cannot have an html form nested within the
    > main form for the page. This means that I have to create a user
    > control that has the form contained within it, make a post back to the
    > server and then redirect the user to the search result page. This is
    > a huge setback in my opinion, am I missing something? is there a
    > better way to handle this?
    >
    > TIA
    > -Josh
    Steve C. Orr [MVP, MCSD], Jan 6, 2004
    #3
  4. Josh Harris

    Josh Harris Guest

    "Steve C. Orr [MVP, MCSD]" <> wrote in message:
    > 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.)
    >
    > It's my understanding that this will become more flexible in .NET version 2.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    > Hire top-notch developers at http://www.able-consulting.com
    >



    I solved the problem by creating a hidden form outside of the server
    form, and then creating a javascript function that is called when the
    submit button is clicked that will call the post method of the hidden
    form.

    Thanks for the replies.
    Josh Harris, Jan 14, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jlopes151
    Replies:
    2
    Views:
    617
    Steve C. Orr [MVP, MCSD]
    Mar 14, 2005
  2. doug
    Replies:
    6
    Views:
    4,625
    Andrew Thompson
    Jan 27, 2004
  3. Toni Pohl
    Replies:
    1
    Views:
    933
    Toni Pohl
    Aug 10, 2008
  4. Keltex
    Replies:
    1
    Views:
    392
    Dominick Baier [DevelopMentor]
    Jan 24, 2006
  5. Eric
    Replies:
    2
    Views:
    480
Loading...

Share This Page