473,500 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validators ok, but code still runs

Hi Folks,
I've got a simple aspx page with a few input controls on with required
fieldvalidators for each and a submit button. The validators work fine
when I click the button without having entered any of the fields.

However, after having added some code behind for the buttons _Click
event to save the data in the database, I have discovered that the
code will run anyway. So on a click, the validators fire up and
correctly display that the fields have not been filled but then the
code runs and saves the blank entry to the database.

Have I missed something somewhere?? I have an example of a similar
situation from some Wrox code, and I can't see any further check in
the code behind....

Any help gratefully received...

Many Thanks,
Pete Baugh
pb****@recoilsoft.com
Nov 18 '05 #1
3 1012
Hi Pete,

It is a strange behavior that can be caused by many things.
Check your Submit button properties under CausesValidation and make sure it
is set to true.
Check your Document(Form) properties and make sure its EnableViewState is
set to true and DefaultCLientScript is set to JScript.
Also check the events of your required fieldvalidators to make sure they are
not associated to an event launch.

Let me know how this works

Patrick

"Pete Baugh" <pb****@recoilsoft.com> wrote in message
news:c6*************************@posting.google.co m...
Hi Folks,
I've got a simple aspx page with a few input controls on with required
fieldvalidators for each and a submit button. The validators work fine
when I click the button without having entered any of the fields.

However, after having added some code behind for the buttons _Click
event to save the data in the database, I have discovered that the
code will run anyway. So on a click, the validators fire up and
correctly display that the fields have not been filled but then the
code runs and saves the blank entry to the database.

Have I missed something somewhere?? I have an example of a similar
situation from some Wrox code, and I can't see any further check in
the code behind....

Any help gratefully received...

Many Thanks,
Pete Baugh
pb****@recoilsoft.com

Nov 18 '05 #2
Pete:

It sounds like the example code doesn't have a check of the IsValid
property (a Page property) in the event handler. On the server side,
everything executes normally and it's up to the developer to check
IsValid and alter the normal flow of logic.

HTH,

--
Scott
http://www.OdeToCode.com

On 1 May 2004 02:31:51 -0700, pb****@recoilsoft.com (Pete Baugh)
wrote:
Hi Folks,
I've got a simple aspx page with a few input controls on with required
fieldvalidators for each and a submit button. The validators work fine
when I click the button without having entered any of the fields.

However, after having added some code behind for the buttons _Click
event to save the data in the database, I have discovered that the
code will run anyway. So on a click, the validators fire up and
correctly display that the fields have not been filled but then the
code runs and saves the blank entry to the database.

Have I missed something somewhere?? I have an example of a similar
situation from some Wrox code, and I can't see any further check in
the code behind....

Any help gratefully received...

Many Thanks,
Pete Baugh
pb****@recoilsoft.com


Nov 18 '05 #3
Thanks for that,
Actually after I posted that I did put in a 'if (isvalid)' check and
the code now works fine (hurrah!). Th only thing that I'm still
scratching my head about is that the WROX example code doesn't mention
isvalid anywhere... and it seems to work fine. Oh well, on to the next
frustrating issue!!

Thanks very much guys,

Peter Baugh
Nov 18 '05 #4

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

Similar topics

13
1121
by: Leon | last post by:
Why this code is not working? I think the problem is in the business class code.when I select a state from the dropdownlist, the school dropdownlist suppose to fill with school names, but somehow...
16
1407
by: Joe Fallon | last post by:
I have a C# class that works correctly. I translated it to VB and now it runs differently. The C# class evaluates the Public properties and then executes MyBase.New. So default values are set...
16
1496
by: nelu | last post by:
I know I can use unsinged byte, but I need it for java, which code runs faster in C? int f1(char b) { return (b&0x80)|(b&0x7f); } or int f2(char b) {
13
3940
by: NDayave | last post by:
How do, For backing up my database(Access 2000), i am trying to just back up the tables and their data, as this will save on space and allow for importing back into the actual database. I want the...
0
1826
by: jigsmshah | last post by:
i am working on a project (windows service using VB.Net and C#) which gets the check details and check images from the database and prints the check to a printer. Printer name is configured in a...
3
1391
by: Academia | last post by:
If the user types into the TextBox of a combobox it works OK. But if he hold a key down so the letter repeats quickly the code runs into trouble. My questions are: Is it true that an event's...
1
1755
by: mbentler | last post by:
I have the following function: Public Function GetDays() As Variant 'Determine the number of days on an insurance policy Dim dteStart As Variant Dim dteEnd As Variant Dim VarDays As...
7
1529
by: Just_a_fan | last post by:
I have a program which runs fine here (created in VB9). I publish it to my web site for download & install. It runs on some computers (one or two) but not others. When it does not run, it causes...
8
2399
by: Henri.Chinasque | last post by:
Hi all, I am wondering if there are any quick/efficient ways to look at a piece of c++ code and determine if it would run faster if it was compiled to native code. I ask this because all of my...
2
1424
by: gtfrueh | last post by:
I have a VB6 project that runs OK under XP, but not under Win98. I have not packaged and deployed. I just copied my working folder of code from the XP machine to the Win98 machine. The code on the...
0
7182
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
7232
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...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
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...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.