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

Discussion in 'ASP .Net' started by nzanella@gmail.com, Jan 12, 2005.

  1. Guest

    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
     
    , Jan 12, 2005
    #1
    1. Advertising

  2. 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]

    <> wrote in message
    news:...
    >
    > 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
    >
     
    Philip Q [MVP], Jan 12, 2005
    #2
    1. Advertising

  3. Peter Blum Guest

    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:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    <> wrote in message
    news:...
    >
    > 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
    >
     
    Peter Blum, Jan 12, 2005
    #3
  4. MattC Guest

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

    MattC
    <> wrote in message
    news:...
    >
    > 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
    >
     
    MattC, Jan 14, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S01aX3N0YXRl?=

    Quick one - Is SESSION per browser instance or per IP Address?

    =?Utf-8?B?S01aX3N0YXRl?=, Apr 4, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,930
    gerry
    Apr 10, 2006
  2. Replies:
    5
    Views:
    2,617
  3. Replies:
    0
    Views:
    365
  4. restricts Access to DLL

    , Jul 13, 2007, in forum: ASP .Net Security
    Replies:
    1
    Views:
    114
  5. Gianni

    IE restricts this webpage message

    Gianni, Jul 10, 2009, in forum: Javascript
    Replies:
    4
    Views:
    156
    Gianni
    Jul 10, 2009
Loading...

Share This Page