views:

29

answers:

1

Hi,

I have a website that was designed by a third party and contains several form, the forms are not nested so the HTML is valid. Now I am trying to port this HTML into an ASP.NET page. The controls in some of the forms require AJAX extenders (some Textboxes with Autocomplete) and I end up having Forms in Forms. The browser does not complain but I know it's wrong.

What is the best approach to porting this into an ASP.NET page? Does an ASP.NET page require multiple forms? The way I am understanding it is that all actions on the page get handled by the one CodeBehind class for this page anyways.

Thanks, Ben

+1  A: 

ASP.NET, out of the box, only allows one form on the page to have runat="server". You can have more forms, but none of them can be so-called "server" forms - that is, only one form can handle postbacks.

The usual way it works is that you just have one form for the whole page, and everything shares that one form. With server controls and the like, it's not usually a big limitation.

If you need more control over the forms and what gets posted where, then ASP.NET MVC does not have this limitation. Of course, building your site in ASP.NET MVC is quite a bit different to building it in ASP.NET "classic"...

Dean Harding
Thanks Dean, that confirmed what I had thought.
b3n