multiple forms on one page

L

Lerp

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>
 
T

TJS

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.
 
R

Raterus

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
 
P

Peter Blum

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

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
 
J

John

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
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top