[thelist] ASP.NET multiple forms question

jason.handby jason.handby at corestar.co.uk
Fri Jul 14 10:35:27 CDT 2006


Hi Rob,

 
> <snip>But in ASP.NET everything has to post back to the page 
> you're on, and you can only have one form tag anyway. However 
> you can still put everything on one page -- you just have to 
> use a different approach to separating out the server-side 
> code. This is where user controls come in handy.</snip>
> 
> Point taken. Let me reiterate what you said so I understand 
> it. I can still have "three separate forms," but with three 
> different Submit buttons. On the .vb of the .aspx file, I can 
> simply have click events for each of those buttons, then I 
> know to look for/validate fields within that scope. 

Yes :-)


> What are the advantages to this vs. the old way in this 
> regard? Nothing comes to mind at the moment.

Suppose you have a search form that you want to include on all your
pages. If you did it the old way you'd have: a piece of HTML you'd add
to each page (or possibly a #include file); and another page that does
the processing once the form was submitted. Oh and if you want
server-side code for setting up the search form then you have to find a
home for that too.

In ASP.NET you can create a user control that contains: the HTML for the
search form, any server-side code for setting it up, and the click event
handler for processing its submission. You can then just drop this
control into any page that needs a search box... Sounds good to me!




Jason



More information about the thelist mailing list