473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

server side validation in form using panel controls

Hi

I have a long form - around 80 fields - which i have decided to break up
into
more manageable sections using the <asp:Panel> control.

Basically i have three panels (stages) containing various form elements
which i show
and as the user progresses through the form.

I need to use server side validation (client side is not an option) on some
of the fields in the form
dive used an <asp:RequiredFieldValidator> as an example here.

I cant seem to get the validation to take effect - you'll see the
<asp:RequiredFieldValidator> in <asp:Panel Id="stage1">
as an example - if the user doesn't enter a value of some kind then i'd like
the same stage returned
not allowing the user to bypass it.

Thanks in advance...

Simon Ames

Here's the code.......

<script language="vb" runat="server">
Sub Page_load
fnHideAllPanels
If not IsPostback then
' show stage 1 on loading page for first time
stage1.Visible = True
End If
End Sub

Sub Button_Click (sender As System.Object, e As
system.Web.UI.WebControls.CommandEventArgs)
If e.CommandName = "move_to_stage_2" Then
If page.isvalid then
' if user has entered a value
stage2.Visible = True
Else
' if field is empty
stage1.Visible = True
End If
ElseIf e.CommandName = "move_to_stage_3" Then
stage3.Visible = True
ElseIf e.CommandName = "move_to_stage_1" Then
stage1.Visible = True
End If
End Sub

Function fnHideAllPanels
stage1.Visible = False
stage2.Visible = False
stage3.Visible = False
End Function
</script>

<form runat="server">
<asp:Panel Id="stage1" RunAt="server" Wrap="">
<h2>Stage One</h2>
<asp:RequiredFieldValidator Id="val_username" RunAt="server"
ControlToValidate="username" EnableClientScript="false" Text="enter a
username" />
<asp:textbox id="username" runat="server"/> * required
<asp:Button Id="move_to_stage_2" CommandName="move_to_stage_2"
OnCommand="button_click" RunAt="server" Text="next"/>
</asp:Panel>

<asp:Panel Id="stage2" RunAt="server" Wrap="">
<h2>Stage Two</h2>
<asp:Button Id="move_to_stage_3" CommandName="move_to_stage_3"
OnCommand="button_click" RunAt="server" Text="next"/>
</asp:Panel>

<asp:Panel Id="stage3" RunAt="server" Wrap="">
<h2>Stage Three</h2>
<asp:Button Id="move_to_stage_1" CommandName="move_to_stage_1"
OnCommand="button_click" RunAt="server" Text="next"/>
</asp:Panel>
</form>
Nov 18 '05 #1
0 1281

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
4
by: earwicker | last post by:
I recently deployed a web application which contains a user registration form with the usual fields: name, address, email, password, etc. Each of the TextBoxes uses a validation control to verify...
1
by: Tony | last post by:
Hi folks, I've got a bit of a problem. I have a situation where I build forms completely dynamically based on a form definition supplied from a database. Anyway, I noticed that required fields...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
4
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all...
3
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server....
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.