[thelist] ASP.NET multiple forms question

jason.handby jason.handby at corestar.co.uk
Fri Jul 14 02:42:10 CDT 2006


Hi Marc,


> Is this true? It seems rather narrow-minded an approach if it 
> really is.
> 
> To give some more background, the page in question has two 
> forms that serve totally different functions. One is a login 
> form the other is a calculator. 
> It doesn't make semantic sense to me to combine these two 
> functions into one form, though I know it is technically possible.


I used to scratch my head over this one...

In some ways, ASP.NET is really a bit more like the Windows Forms
environment than the traditional web. Once you've dropped your
runat="server" controls onto your HTML page, you can access their
properties and call their methods from the code-behind file. ASP.NET
takes care of the actual posting and updating of data to and from the
server, so you don't really have to get involved in all of that.

So I guess you could say the semantics of the form tag have changed in
ASP.NET. ASP.NET requires a form tag on a web page so that it can do the
behind-the-scenes posting required to make your page work. That's why it
automatically creates one form on a new page. But the idea is that you
won't ever have to think about form tags -- they've just become part of
the background mechanism.

This does mean that you can no longer use the form tag as a way of
"parcelling up" pieces of functionality on the page. (One for the login,
one for the calculator, in your example.) If you want to parcel up a
piece of HTML with the associated code-behind required to make it work,
maybe you could talk to your ASP.NET developer about user controls?

  http://www.asp101.com/lessons/usercontrols.asp
  http://www.oreilly.com/catalog/progaspdotnet/chapter/ch14.html


HTH




Jason



More information about the thelist mailing list