multiple forms in asp.net

J

Josh Harris

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
 
K

Kevin Spencer

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.
 
S

Steve C. Orr [MVP, MCSD]

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.
 
J

Josh Harris

Steve C. Orr said:
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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top