Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   ASP.NET restricts server forms to one per page... workarounds... ??? (http://www.velocityreviews.com/forums/t94305-asp-net-restricts-server-forms-to-one-per-page-workarounds.html)

nzanella@gmail.com 01-12-2005 04:17 AM

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

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/is...5/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


Philip Q [MVP] 01-12-2005 06:11 AM

Re: ASP.NET restricts server forms to one per page... workarounds... ???
 
There are several options available to you, take a look at the article -
http://aspalliance.com/415
Some of the methods are quite messy, but can be simplified depending on your
situation.

--
Philip Q
Microsoft MVP [ASP.NET]

<nzanella@gmail.com> wrote in message
news:1105503454.699694.53730@c13g2000cwb.googlegro ups.com...
>
> 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/is...5/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
>




Peter Blum 01-12-2005 07:30 PM

Re: ASP.NET restricts server forms to one per page... workarounds... ???
 
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: PLBlum@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

<nzanella@gmail.com> wrote in message
news:1105503454.699694.53730@c13g2000cwb.googlegro ups.com...
>
> 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/is...5/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
>




MattC 01-14-2005 04:54 PM

Re: ASP.NET restricts server forms to one per page... workarounds... ???
 
Just set CausesValidation=false on both buttons and handle the validation in
teh code behind for the value relating to the button clicked.

MattC
<nzanella@gmail.com> wrote in message
news:1105503454.699694.53730@c13g2000cwb.googlegro ups.com...
>
> 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/is...5/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
>





All times are GMT. The time now is 11:51 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.