473,624 Members | 2,273 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****@recoilso ft.com
Nov 18 '05 #1
3 1021
Hi Pete,

It is a strange behavior that can be caused by many things.
Check your Submit button properties under CausesValidatio n and make sure it
is set to true.
Check your Document(Form) properties and make sure its EnableViewState is
set to true and DefaultCLientSc ript 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****@recoils oft.com> wrote in message
news:c6******** *************** **@posting.goog le.com...
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****@recoilso ft.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****@recoilso ft.com (Pete Baugh)
wrote:
Hi Folks,
I've got a simple aspx page with a few input controls on with required
fieldvalidator s 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****@recoils oft.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
1135
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 the state value is not getting back to the business class. I think it's the way I'm using property get and set accessor function. ****My Business Class------------ ' Private variables
16
1425
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 first and then MyBase.New reads in new values (if they exist.) The VB code does it in reverse. It excutes MyBase.New and then overwrites the new values when it sets the defaults.
16
1510
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
3954
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 data copied into a dated backup database so a specific restore can be performed and old backups arent lost. The vb code i have makes a new blank database and copies the data into tables through docmd.runSQL. Both aspects of the code work fine; the...
0
1854
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 XML file. Printer names are names which are available to the system on which the service is running. Printers used are network printers and are added using Printers and Faxes -> Add a printer. To validate the printer I am using the following...
3
1402
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 code is normally run to completion before another event's code is entered (KeyUp in my case)? If that is true and there are exceptions that let another event start do they include:
1
1760
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 Variant Dim Insurance As Variant
7
1535
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 a reporting and submission window to pop up. It seems something is missing. This program was converted from a VB6 original piece. Unfortunately, I started on the .NET path just a couple of weeks after getting this app going. I have...
8
2404
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 c++ is currently compiled with the /clr flag meaning that nothing is compiled native. I've seen some examples where wrapping arithmetically intense code with "pragma unmanaged" results in increased performance, but this was in test code with...
2
1434
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 Win98 machine runs about 95% successful. The problem is this: I have a timer that, when it goes off, decrements a variable. The variable is used in my mainform, in a loop. I set breakpoints in the timer code and have verified that the variable is...
0
8233
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6108
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4078
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
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 we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.