Yes Virginia, You Can Have Multiple Server Forms in ASP.NET

A current article in MSDN Magazine by a respected author is just wrong -- you can have multiple server forms in ASP.NET, and they can post to other pages.  For those of you that still aren't aware of this, my WilsonWebForm has been around for quite some time, and its been totally free and open source for a while now too:

The ASP.NET WilsonWebForm enables Multiple Forms and Non-PostBack Forms, finally allowing you to overcome this built-in ASP.NET restriction. This is a real Server Form that supports WebControls, ViewState, and Events, as well as the Action attribute to Post to other pages/sites. The only limitation is that Validation controls are not supported, but a single regular server form can still be used at the same time. The typical usage is to continue to use the regular server form for the main page content, with validators, while using the WilsonWebForm for small side forms for things like search, login, or preferences. The source code of this control is available in both C# and VB.NET, along with a simple demo application that fully show's how to use it.

I can probably even update it to support validators in ASP.NET v2, since the problem was only the fact that the ASP.NET model assumed all validators we're scoped to the whole page, but now with ASP.NET v2 there are validation groups -- so maybe I'll get around to looking at this, or someone else can since its open source.  :)

Note:  I do agree that the ASP.NET single-form approach simplifies development and it should not be discarded lightly just because you can.  But the fact is that all web browsers do support multiple forms (can someone say "standard"), they do make some things easier (can someone say multiple default buttons without javascript), and they are sometimes even required (ever need to post to an external site).  So while I applaud the ASP.NET team for trying to simplify things, I do not agree with the approach that completely eliminates the use of a wide-spread standard approach that is sometimes even required -- all in the name of simplicity.  Its actually almost funny watching them now add back some work-arounds for cross-page posting, default buttons, and validation groups -- things that would all have automatically been supported in the first place.  :)

No Comments