473,729 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RequiredValidat or not working

I have the following:

<asp:textbox id="ProfileName " columns="45" runat="server" />
<asp:RequiredFi eldValidator
ControlToValida te="ProfileName "
Display="Dynami c"
Text="Name Required"
runat="server" />

I also have an imagebutton that goes to a routine to save a record

<asp:ImageButto n ID="SaveRecord " runat="server" Visible="true"
OnClick="Modify Record_Click" ImageUrl="../../buttons/SaveChanges_0.g if" />

I put nothing in the ProfileName field and it still goes to the function
ModifyRecord_Cl ick instead of displaying the "Name Required" message.

Why is it not working?

Thanks,

Tom
Nov 19 '05 #1
7 3566
TJS
I have a similar problem and wonder if this is like mine.

Are you having this problem in both IE and Firefox browsers ?
Are you prepopulating the field for the user to show the current value from
a datastore ?
Nov 19 '05 #2
"TJS" <no****@here.co m> wrote in message
news:uJ******** ******@TK2MSFTN GP15.phx.gbl...
I have a similar problem and wonder if this is like mine.

Are you having this problem in both IE and Firefox browsers ?
Are you prepopulating the field for the user to show the current value
from a datastore ?


Actually,

It does it with both.

But I also was getting an error before in the function the button was
calling, so I assume the validator wasn't being called.

I assumed that because I got the error, the validator didn't work.

What is happening is that the function is being called after the Validator
has run?

I thought if there was an error, the function wouldn't be called. Am I
wrong here?

Thanks,

Tom

Nov 19 '05 #3
TJS
You're right, the function should not be called if the page is not valid

since it fails in both browsers, and you aren't prefilling the form, I would
need to see your code for "ModifyRecord_C lick" to determine of the problem
is there.


Nov 19 '05 #4
"TJS" <no****@here.co m> wrote in message
news:uN******** *****@TK2MSFTNG P15.phx.gbl...
You're right, the function should not be called if the page is not valid

since it fails in both browsers, and you aren't prefilling the form, I
would need to see your code for "ModifyRecord_C lick" to determine of the
problem is there.


Actually, what I did to make it work is:

Sub ModifyRecord_Cl ick(sendor as Object, e as ImageClickEvent Args)

if not Page.isValid then
exit Sub
End If

I guessed the function does get called, so I just added that code to solve
the problem.

Tom
Nov 19 '05 #5
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OS******** ******@TK2MSFTN GP09.phx.gbl...
"TJS" <no****@here.co m> wrote in message
news:uN******** *****@TK2MSFTNG P15.phx.gbl...
You're right, the function should not be called if the page is not valid

since it fails in both browsers, and you aren't prefilling the form, I
would need to see your code for "ModifyRecord_C lick" to determine of the
problem is there.


Actually, what I did to make it work is:

Sub ModifyRecord_Cl ick(sendor as Object, e as ImageClickEvent Args)

if not Page.isValid then
exit Sub
End If

I guessed the function does get called, so I just added that code to solve
the problem.

Tom

Nov 19 '05 #6
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OS******** ******@TK2MSFTN GP09.phx.gbl...
"TJS" <no****@here.co m> wrote in message
news:uN******** *****@TK2MSFTNG P15.phx.gbl...
You're right, the function should not be called if the page is not valid

since it fails in both browsers, and you aren't prefilling the form, I
would need to see your code for "ModifyRecord_C lick" to determine of the
problem is there.

Actually, what I did to make it work is:

Sub ModifyRecord_Cl ick(sendor as Object, e as ImageClickEvent Args)

if not Page.isValid then
exit Sub
End If

I guessed the function does get called, so I just added that code to solve
the problem.


Now the problem is in my other routine, which is called by my LinkButton
(the Modify routine was called by an ImageButton).

The code is the same:

Sub DeleteProfile_C lick(sender as Object, e as EventArgs)
trace.warn("ins ide SelectProfile")

if not Page.isValid then
exit Sub
End If

But when I do it I get the error:

Page.IsValid cannot be called before validation has taken place. It should
be queried in the event handler for a control with CausesValidatio n=True or
after a call to Page.Validate.

So in the Modify function, the validate function is being called and in the
Delete function it is not ???????

Tom Tom

Nov 19 '05 #7
The method Page.Validate() is called automatically by each of Microsoft's
submit controls (Button, ImageButton, and LinkButton) unless you set
CausesValidatio n to false. If its not called, you cannot use Page.IsValid as
you've found.

The submit controls call it in their OnClick method (which then fires your
Click event handler). It runs after Page_Load.
- Make sure CausesValidatio n=true or you call Page.Validate() before calling
Page.IsValid
- Don't call any of this from within Page_Load. Let it happen in the post
back event methods.
- If you are using CausesValidatio n=false because you don't want to validate
every validator, call individual validator's Validate() methods. Then check
the IsValid property on those individual validators.
- This is all server side code. It should not be affected by the browser
type.
- It is possible that if javascript is not working, your Click post back
event will not run. This happens when your submit control calls
__doPostBack() on the client-side to set itself up for server side
processing. Without javascript running, __doPostBack() never runs.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"tshad" <ts**********@f tsolutions.com> wrote in message
news:OF******** ********@TK2MSF TNGP14.phx.gbl. ..
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OS******** ******@TK2MSFTN GP09.phx.gbl...
"TJS" <no****@here.co m> wrote in message
news:uN******** *****@TK2MSFTNG P15.phx.gbl...
You're right, the function should not be called if the page is not valid

since it fails in both browsers, and you aren't prefilling the form, I
would need to see your code for "ModifyRecord_C lick" to determine of the
problem is there.


Actually, what I did to make it work is:

Sub ModifyRecord_Cl ick(sendor as Object, e as ImageClickEvent Args)

if not Page.isValid then
exit Sub
End If

I guessed the function does get called, so I just added that code to
solve the problem.


Now the problem is in my other routine, which is called by my LinkButton
(the Modify routine was called by an ImageButton).

The code is the same:

Sub DeleteProfile_C lick(sender as Object, e as EventArgs)
trace.warn("ins ide SelectProfile")

if not Page.isValid then
exit Sub
End If

But when I do it I get the error:

Page.IsValid cannot be called before validation has taken place. It should
be queried in the event handler for a control with CausesValidatio n=True
or after a call to Page.Validate.

So in the Modify function, the validate function is being called and in
the Delete function it is not ???????

Tom
Tom


Nov 19 '05 #8

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

Similar topics

3
2933
by: SStory | last post by:
Is there no way to require a checkbox to be checked in ASP.NET? The requiredvalidator control doesn't work for it--should I make a server--roundtrip for that and check during the btn_click event? Is there another way? Thanks, Shane
5
2809
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We have been looking our asses off but can not find a working solution. the code we came up with is ...
1
2787
by: Elie Medeiros via .NET 247 | last post by:
Hi there, I have written a custom validator function to validate a datefrom a user-filled field. The function tries to parse the dateand if it can't, sets (serverValidateEventArgs)e.IsValid tofalse. The twist is that it allows blank dates to be entered - viz,e.IsValid==true if the field is left blank. The idea is to usethat validation control to make sure the date a user has enteredis valid, without the date field being required to...
3
2093
by: TJS | last post by:
I am finding that the serverside requiredvalidator doesn't fire in the firefox browser, and user request proceeds through to my updateProfile method. Validation is working correctly in the IE browser. Anyone seen this problem or have any ideas why this might be occurring ?? (I have web.config browsercaps updated from http://slingfive.com/ ) code: =========
5
3057
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find out why it quit working. I found that if I didn't have a linkbutton, it quit working????????? If I changed the linkbutton to a regular button, it quit working. Here is the page:
8
2532
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs file (present under the Properties folder of the project) 3. Now I created a file called test.js on the root folder of the project,
9
3217
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. What it does is to call a webservice with two parameters, one being a integer, the other one being a "String" which contains XML (not the best practice, however that is the target interface and we cannot change that).
4
3441
by: Shimon Sim | last post by:
hi It should be easy but I can't make it work. I have DropDownList. I set first with text and value "Select". Then I add RequiredValidator and set it InitialValue to "Select" and I expect that the validator will not allow this value to stay the same but.. Validator never fires. What is wrong? Thank you, Shimon.
2
1687
by: Niraj Sikotara | last post by:
hello, i'm using ASP.NET 2.0, and have placed validators on a page that are not working correctly in FireFox (1.5.0.7) the page can be downloaded from http://ez-files.net/download.php?file=e0d71170 i've googled groups but not found any proper answer,
0
9426
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
9280
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...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
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
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
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...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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
2
2677
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.