473,386 Members | 1,795 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,386 software developers and data experts.

Why has my validation stopped working? [1/1]

Hello,

I have been playing with some of the code in ASP.NET Unleashed, to try
and understand what's going on. I am getting on pretty well, but have
struck a problem. I was looking at samples for hiding panels, to do
multistep forms, and then at validation.

All was going well and I was getting the hang of validation, when it
just stopped working. I'm not sure what I did, and the code compiles and
runs fine, but the required fields can be left empty without an error.

I have included the code below. Sorry it's a bit long, but I'm not
fluent enough at it to work out which bits to chop out yet!!

Thanks for any help.

Alan


--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #1
4 1493
Alan:
You've set the EnableClientScript="false" in your validation controls, which
is all fine and good, but you'll probably be surprised to know that
server-side validation doesn't happen automatically like client-side does.

In your next-prev buttons (or in any buttons/events/place you want to
validate) you need to do:

void btnNextPage_Click( object s, EventArgs e ) {
Page.Validate();
if (Page.IsValid){
//your normal code here
}
}

Hope this helps,
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:JK**************@nospamthankyou.spam...
Hello,

I have been playing with some of the code in ASP.NET Unleashed, to try
and understand what's going on. I am getting on pretty well, but have
struck a problem. I was looking at samples for hiding panels, to do
multistep forms, and then at validation.

All was going well and I was getting the hang of validation, when it
just stopped working. I'm not sure what I did, and the code compiles and
runs fine, but the required fields can be left empty without an error.

I have included the code below. Sorry it's a bit long, but I'm not
fluent enough at it to work out which bits to chop out yet!!

Thanks for any help.

Alan

----------------------------------------------------------------------------
----



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #2
>Alan:
You've set the EnableClientScript="false" in your validation controls, which
is all fine and good, but you'll probably be surprised to know that
server-side validation doesn't happen automatically like client-side does.
Ah ha, that would explain why it stopped working. I had only just added
that bit. Client-side validation wasn't happening anyway (possibly the
JS files were missing, but nothing happened) and I tried turning it off.
I did a couple of other changes at the same time and forgot that I had
changed this bit.

Please explain *why* this happens, I don't see the logic that says that
server-side validation only happens automatically when client-side
validation is enabled. Surely the two should be independent? Why does
turning off client-side also turn off server-side? More to the point,
can I have automatic server-side validation without having client-side?

Also, does server-side get turned off if I disable client-side for just
one control, or is it only when I disable it for all controls?
In your next-prev buttons (or in any buttons/events/place you want to
validate) you need to do:

void btnNextPage_Click( object s, EventArgs e ) {
Page.Validate();
if (Page.IsValid){
//your normal code here
}
}

Hope this helps,


Sure does, thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #3
Alan,
You can automatically get server-side validation by setting the
CausesValidation attribute to true in the button/linkbutton doing postback,
ala:

<asp:Button Text="Next Page >>" OnClick="btnNextPage_Click"
CausesValidation="True" Runat="Server" ID="Button1"/>

you still need to wrap your button codebehind code in a if
(Page.IsValide){ } which makes sense since the postback is still occuring
and you might wanna do something on the server side if it isn't...

Hope this helps,

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:IM**************@nospamthanx.spam...
Alan:
You've set the EnableClientScript="false" in your validation controls, whichis all fine and good, but you'll probably be surprised to know that
server-side validation doesn't happen automatically like client-side
does.
Ah ha, that would explain why it stopped working. I had only just added
that bit. Client-side validation wasn't happening anyway (possibly the
JS files were missing, but nothing happened) and I tried turning it off.
I did a couple of other changes at the same time and forgot that I had
changed this bit.

Please explain *why* this happens, I don't see the logic that says that
server-side validation only happens automatically when client-side
validation is enabled. Surely the two should be independent? Why does
turning off client-side also turn off server-side? More to the point,
can I have automatic server-side validation without having client-side?

Also, does server-side get turned off if I disable client-side for just
one control, or is it only when I disable it for all controls?
In your next-prev buttons (or in any buttons/events/place you want to
validate) you need to do:

void btnNextPage_Click( object s, EventArgs e ) {
Page.Validate();
if (Page.IsValid){
//your normal code here
}
}

Hope this helps,


Sure does, thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #4
Thanks Karl, I think it helps!!

I think I'll leave client-side enabled for the minute and worry about
the major issues first. I am actually getting the hang of this slowly!

Thanks

a
Alan,
You can automatically get server-side validation by setting the
CausesValidation attribute to true in the button/linkbutton doing postback,
ala:

<asp:Button Text="Next Page >>" OnClick="btnNextPage_Click"
CausesValidation="True" Runat="Server" ID="Button1"/>

you still need to wrap your button codebehind code in a if
(Page.IsValide){ } which makes sense since the postback is still occuring
and you might wanna do something on the server side if it isn't...

Hope this helps,

Karl


--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #5

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

Similar topics

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...
4
by: vzaffiro | last post by:
Our Development Server (windows 2003, framework 1.1) was working great for months, then one day all the client side validators stopped working. Only the server side validation is working. Our code...
10
by: Tom | last post by:
I have created a new site, using asp.net c#. My pages contain client side validation to validate the users input. On my local machine this works fine, but when I moved my site to the test server,...
1
by: Dennis Calla | last post by:
I recently moved my app to a hosted environment and the validation stopped working (i had it on my own webserver). I put an alert in the validation javascript file so I know it is being called. ...
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
9
by: Alan Silver | last post by:
Hello, I have some simple client-side Javascript validation that was working fine until now. For some reason (don't ask me), it has stopped working and I can't figure out why. I have switched to...
2
by: dustbort | last post by:
I recently had a problem where my required field validator stopped working. But, the page still posted back and tried to insert a record into the database without performing server-side validation....
3
by: Just D. | last post by:
All, Did anybody see this bug? We're having two login pages in a huge application, both are with validation controls. Everything works just great on two developer's machines working under...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.