ASP.NET restricts server forms to one per page... workarounds... ???

N

nzanella

Hello,

I just ran into the restriction of ASP.NET allowing no more than
one <form> tag with the runat="server" attribute per page. This
seems like a big restriction to me. I ran across the following
article:

http://msdn.microsoft.com/msdnmag/issues/03/05/CuttingEdge/

which suggests the following workaround (which consists of
defining user controls for the contents of each form and
incorporating the result into one single form):

<form runat="server">
<msdn:MyRegForm runat="server" id="userRegForm"
action="register.aspx" />
<hr>
<msdn:MyLogForm runat="server" id="userLogForm"
action="login.aspx" />
</form>

However, I was not satisfied with this solution. The reason
is that if there are ASP validation controls on both forms
then error messages will be displayed for Form B whenever
the user submits Form A and conversely, which is plain
incorrect. So the solution described therein is just
not really a solution.

What I am going to do is ditch the ASP.NET framework's
web controls altogether and code my pages PHP style,
with ASP and no .NET, and manage my own POST variables.

Is there another way that actually works and isn't messy?
Regards,

Thanks,

Neil
 
P

Peter Blum

The Validation issue is solvable. Microsoft will fix it in ASP.NET 2.0 by
introducing Validation Groups. This allows you to assign a group name to a
submit button and the validators it fires.

Today, my "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) already gives you validation groups
along with numerous other much requested enhancements to validation such as
client-side validation on the Mozilla browsers, Opera 7 and Safari.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
M

MattC

Just set CausesValidation=false on both buttons and handle the validation in
teh code behind for the value relating to the button clicked.

MattC
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top