multiple forms on one page

Discussion in 'ASP .Net' started by TJS, Jun 8, 2004.

  1. TJS

    TJS Guest

    what are folks doing to get around limitation of one server form per page ?
     
    TJS, Jun 8, 2004
    #1
    1. Advertising

  2. TJS

    Lerp Guest

    Hi there,

    Use one big form and sepearate the sections using panels is one way of
    getting over that. You can toggle the visible property of the panel (part
    of fomr in question) when needed by setting its visible property to true.


    Cheers, Lerp :)



    Here's an example:


    Sub ChangePanelVisibility(Sender As Object, E As EventArgs)

    If Sender.Text = "Show Panel One" Then
    myFirstPanel.visible = true ' SET TO TRUE HERE
    mySecondPanel.visible = false
    myThirdPanel.visible = false
    myFourthPanel.visible = false
    End If

    End Sub



    <form ID="myForm" runat="server">

    <asp:panel ID="myFirstPanel" CssClass="myCssClass" runat="server">
    First section of form
    </asp:panel>

    <asp:panel ID="mySecondPanel" CssClass="myCssClass" runat="server">
    Second section of form
    </asp:panel>

    <asp:panel ID="myThirdPanel" CssClass="myCssClass" runat="server">
    Third section of form
    </asp:panel>

    <asp:panel ID="myFourthPanel" CssClass="myCssClass" runat="server">
    Fourth section of form
    </asp:panel>



    <asp:Button id="ShowPanelOneButton" text="Show Panel One"
    OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    <asp:Button id="ShowPaneltwoButton" text="Show Panel Two"
    OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    etc...one button for each panel if you wish here...
    </form>




    "TJS" <> wrote in message
    news:...
    > what are folks doing to get around limitation of one server form per page

    ?
    >
    >
     
    Lerp, Jun 8, 2004
    #2
    1. Advertising

  3. TJS

    TJS Guest

    by multiple forms I mean they are all visible all the time. such as a
    search form and a logon form etc.

    the problem seems to be with the validation. The page wants to validate all
    forms and therefore prevents any form from being submitted.

    I didn't want to have to write validation in the onclick events area. I was
    hoping to keep it in the template area.


    "Lerp" <> wrote in message
    news:%...
    > Hi there,
    >
    > Use one big form and sepearate the sections using panels is one way of
    > getting over that. You can toggle the visible property of the panel (part
    > of fomr in question) when needed by setting its visible property to true.
    >
    >
    > Cheers, Lerp :)
    >
    >
    >
    > Here's an example:
    >
    >
    > Sub ChangePanelVisibility(Sender As Object, E As EventArgs)
    >
    > If Sender.Text = "Show Panel One" Then
    > myFirstPanel.visible = true ' SET TO TRUE HERE
    > mySecondPanel.visible = false
    > myThirdPanel.visible = false
    > myFourthPanel.visible = false
    > End If
    >
    > End Sub
    >
    >
    >
    > <form ID="myForm" runat="server">
    >
    > <asp:panel ID="myFirstPanel" CssClass="myCssClass" runat="server">
    > First section of form
    > </asp:panel>
    >
    > <asp:panel ID="mySecondPanel" CssClass="myCssClass" runat="server">
    > Second section of form
    > </asp:panel>
    >
    > <asp:panel ID="myThirdPanel" CssClass="myCssClass" runat="server">
    > Third section of form
    > </asp:panel>
    >
    > <asp:panel ID="myFourthPanel" CssClass="myCssClass" runat="server">
    > Fourth section of form
    > </asp:panel>
    >
    >
    >
    > <asp:Button id="ShowPanelOneButton" text="Show Panel One"
    > OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    > <asp:Button id="ShowPaneltwoButton" text="Show Panel Two"
    > OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    > etc...one button for each panel if you wish here...
    > </form>
    >
    >
    >
    >
    > "TJS" <> wrote in message
    > news:...
    > > what are folks doing to get around limitation of one server form per

    page
    > ?
    > >
    > >

    >
    >
     
    TJS, Jun 8, 2004
    #3
  4. TJS

    Raterus Guest

    Raterus, Jun 8, 2004
    #4
  5. TJS

    Raterus Guest

    If a button doesn't need to trigger validation, you can always set the causesvalidation property to false. From what I've read, there will be Validation Groups in ASP.NET 2.0

    "TJS" <> wrote in message news:...
    > by multiple forms I mean they are all visible all the time. such as a
    > search form and a logon form etc.
    >
    > the problem seems to be with the validation. The page wants to validate all
    > forms and therefore prevents any form from being submitted.
    >
    > I didn't want to have to write validation in the onclick events area. I was
    > hoping to keep it in the template area.
    >
    >
    > "Lerp" <> wrote in message
    > news:%...
    > > Hi there,
    > >
    > > Use one big form and sepearate the sections using panels is one way of
    > > getting over that. You can toggle the visible property of the panel (part
    > > of fomr in question) when needed by setting its visible property to true.
    > >
    > >
    > > Cheers, Lerp :)
    > >
    > >
    > >
    > > Here's an example:
    > >
    > >
    > > Sub ChangePanelVisibility(Sender As Object, E As EventArgs)
    > >
    > > If Sender.Text = "Show Panel One" Then
    > > myFirstPanel.visible = true ' SET TO TRUE HERE
    > > mySecondPanel.visible = false
    > > myThirdPanel.visible = false
    > > myFourthPanel.visible = false
    > > End If
    > >
    > > End Sub
    > >
    > >
    > >
    > > <form ID="myForm" runat="server">
    > >
    > > <asp:panel ID="myFirstPanel" CssClass="myCssClass" runat="server">
    > > First section of form
    > > </asp:panel>
    > >
    > > <asp:panel ID="mySecondPanel" CssClass="myCssClass" runat="server">
    > > Second section of form
    > > </asp:panel>
    > >
    > > <asp:panel ID="myThirdPanel" CssClass="myCssClass" runat="server">
    > > Third section of form
    > > </asp:panel>
    > >
    > > <asp:panel ID="myFourthPanel" CssClass="myCssClass" runat="server">
    > > Fourth section of form
    > > </asp:panel>
    > >
    > >
    > >
    > > <asp:Button id="ShowPanelOneButton" text="Show Panel One"
    > > OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    > > <asp:Button id="ShowPaneltwoButton" text="Show Panel Two"
    > > OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    > > etc...one button for each panel if you wish here...
    > > </form>
    > >
    > >
    > >
    > >
    > > "TJS" <> wrote in message
    > > news:...
    > > > what are folks doing to get around limitation of one server form per

    > page
    > > ?
    > > >
    > > >

    > >
    > >

    >
    >
     
    Raterus, Jun 8, 2004
    #5
  6. Saravana [MVP], Jun 9, 2004
    #6
  7. TJS

    Peter Blum Guest

    My product, "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx, is a replacement for Microsoft's
    validators. It includes "validation groups". Validation groups lets you
    assign a group name to a button and the validators it fires. Professional
    Validation And More is designed to overcome the numerous limitations of
    Microsoft's validators. I've put together a list of the limitations at
    http://www.peterblum.com/vam/valmain.aspx. Of the 19 limitations, only two
    are solved in next year's ASP.NET 2.0: validation groups and setting focus
    to the field with the error.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Raterus" <> wrote in message
    news:...
    If a button doesn't need to trigger validation, you can always set the
    causesvalidation property to false. From what I've read, there will be
    Validation Groups in ASP.NET 2.0

    "TJS" <> wrote in message
    news:...
    > by multiple forms I mean they are all visible all the time. such as a
    > search form and a logon form etc.
    >
    > the problem seems to be with the validation. The page wants to validate

    all
    > forms and therefore prevents any form from being submitted.
    >
    > I didn't want to have to write validation in the onclick events area. I

    was
    > hoping to keep it in the template area.
    >
    >
    > "Lerp" <> wrote in message
    > news:%...
    > > Hi there,
    > >
    > > Use one big form and sepearate the sections using panels is one way of
    > > getting over that. You can toggle the visible property of the panel

    (part
    > > of fomr in question) when needed by setting its visible property to

    true.
    > >
    > >
    > > Cheers, Lerp :)
    > >
    > >
    > >
    > > Here's an example:
    > >
    > >
    > > Sub ChangePanelVisibility(Sender As Object, E As EventArgs)
    > >
    > > If Sender.Text = "Show Panel One" Then
    > > myFirstPanel.visible = true ' SET TO TRUE HERE
    > > mySecondPanel.visible = false
    > > myThirdPanel.visible = false
    > > myFourthPanel.visible = false
    > > End If
    > >
    > > End Sub
    > >
    > >
    > >
    > > <form ID="myForm" runat="server">
    > >
    > > <asp:panel ID="myFirstPanel" CssClass="myCssClass" runat="server">
    > > First section of form
    > > </asp:panel>
    > >
    > > <asp:panel ID="mySecondPanel" CssClass="myCssClass" runat="server">
    > > Second section of form
    > > </asp:panel>
    > >
    > > <asp:panel ID="myThirdPanel" CssClass="myCssClass" runat="server">
    > > Third section of form
    > > </asp:panel>
    > >
    > > <asp:panel ID="myFourthPanel" CssClass="myCssClass" runat="server">
    > > Fourth section of form
    > > </asp:panel>
    > >
    > >
    > >
    > > <asp:Button id="ShowPanelOneButton" text="Show Panel One"
    > > OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    > > <asp:Button id="ShowPaneltwoButton" text="Show Panel Two"
    > > OnClick="ChangePanelVisibility" runat="server" CssClass="but" />
    > > etc...one button for each panel if you wish here...
    > > </form>
    > >
    > >
    > >
    > >
    > > "TJS" <> wrote in message
    > > news:...
    > > > what are folks doing to get around limitation of one server form per

    > page
    > > ?
    > > >
    > > >

    > >
    > >

    >
    >
     
    Peter Blum, Jun 9, 2004
    #7
  8. TJS

    John Guest

    On stuff like a login/password field, or a search field, there's not
    often much need for client-side validation (may still do some of your own
    server-side, or write one or two of your own javascripts), so the buttons
    associated with those fields shouldn't really need to trigger validation
    controls, so you can turn validation off on those particular buttons. If
    there aren't any validation controls associated with your login or search
    fields, other buttons shouldn't try to validate them, either. Should solve
    the validation issue.

    You can also go old-school and put a couple of non-runat=server forms..
    I think IBuySpy does this. Not sure it solves more problems than it creates.
    I saw a site the other day that actually had a little login form that was
    done as an embedded flash movie.

    Another small issue with having multiple forms/buttons on the same page
    will be what button gets clicked/submitted when you hit the 'enter' key. You
    can have someone fill out a new user registration form, hit enter, and
    suddenly they're being taken to your search results page (ack). There are
    alot of examples in these forums and on the web on how to fix that, though.

    It really hasn't been too bad to separate it out a little bit, either..
    put a link to login, but put the form on its own page, etc. After all, if
    you've set up authentication, it's good to have a login page to redirect
    users to if they try to access a resource that doesn't allow anonymous...
    although from a usability standpoint it can be nice to have these useful
    fields right there at the user's fingertips at all times.

    Anyway, good luck!

    -John

    "TJS" <> wrote in message
    news:...
    > by multiple forms I mean they are all visible all the time. such as a
    > search form and a logon form etc.
    >
    > the problem seems to be with the validation. The page wants to validate

    all
    > forms and therefore prevents any form from being submitted.
    >
    > I didn't want to have to write validation in the onclick events area. I

    was
    > hoping to keep it in the template area.
    >
     
    John, Jun 10, 2004
    #8
    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. Ben Turner
    Replies:
    2
    Views:
    526
    Saravana
    Jul 31, 2003
  2. Pint

    multiple forms on one page

    Pint, Jul 19, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    527
    =?Utf-8?B?UmFrZXNoIFJhamFu?=
    Jul 19, 2005
  3. loveNUNO
    Replies:
    2
    Views:
    934
    loveNUNO
    Nov 20, 2003
  4. Phillip Windell

    Multiple submit forms on one page

    Phillip Windell, Jan 14, 2004, in forum: ASP General
    Replies:
    1
    Views:
    136
    Phillip Windell
    Jan 14, 2004
  5. c676228

    multiple forms in one asp page?

    c676228, Oct 25, 2006, in forum: ASP General
    Replies:
    5
    Views:
    223
    Steven Cheng[MSFT]
    Nov 8, 2006
Loading...

Share This Page