I cant seem to get my custom validation to work. can anyone spot where i
have gone wrong
control
<asp:CustomValidator ID="checkHandicap" runat="server"
ControlToValidate="startHandicap" ErrorMessage="Handicap out of range"
OnServerValidate="checkHandicap_ServerValidate" ></asp:CustomValidator>
code behind
Protected Sub checkHandicap_ServerValidate(ByVal source As Object, ByVal
args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
checkHandicap.ServerValidate
Dim ans As Integer = Integer.Parse(args.Value)
Try
If ans -27 And ans <= 27 Then
args.IsValid = True
Exit Sub
End If
Catch exc As Exception
End Try
args.IsValid = False
End Sub 14 2597
Slim,
Are you getting an error message? What values are failing? I mocked up
an example using your code, but don't know how it's failing for you so
I don't really know how to help.
dkb
I get no error, but I get no return either,
from what tests I could do, the function was not firing
"Dblood" <db*********@infinitechs.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Slim,
Are you getting an error message? What values are failing? I mocked up
an example using your code, but don't know how it's failing for you so
I don't really know how to help.
dkb
Slim,
On the mockup I created, the event fired, and your code worked. I
don't see a reason why it would not work. I copied your control
declaration from the post, copied the code from the post. I dumped them
into a page, added the withevents declaration of the checkhandicap
variable, added a button (so that I could have the page postback) and
it worked.
There must be more to the problem. What is causing postback in your
app? Can you set a breakpoint, then run in debug and verify that the
checkHandicap_ServerValidate Sub is not being called? If not, add a
"response.write(args.IsValid)" at each of the conditions (where
args.IsValid is set to true or false) to ensure that the app is calling
the sub.
This is a weird one,
dkb
"Dblood" <db*********@infinitechs.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
Slim,
On the mockup I created, the event fired, and your code worked. I
don't see a reason why it would not work. I copied your control
declaration from the post, copied the code from the post. I dumped them
into a page, added the withevents declaration of the checkhandicap
variable,
where do i put the with events?
added a button (so that I could have the page postback) and
it worked.
There must be more to the problem. What is causing postback in your
app? Can you set a breakpoint, then run in debug and verify that the
checkHandicap_ServerValidate Sub is not being called? If not, add a
"response.write(args.IsValid)" at each of the conditions (where
args.IsValid is set to true or false) to ensure that the app is calling
the sub.
This is a weird one,
dkb
What I mean is that when I copied your control (the text below) to an
aspx page, it didn't create the variable for me on the code-behind
page.
<asp:CustomValidator ID="checkHandicap" runat="server"
ControlToValidate="startHandicap" ErrorMessage="Handicap out of range"
OnServerValidate="checkHandicap_ServerValidate"></asp:CustomValidator>
So, I had to create that variable myself. Yours is probably already
there. Near the top of the code-behind view you'll see:
Protected WithEvents checkHandicap As CustomValidator
Any luck using the Response.write to see if the isvalid ever changes?
Can you debug the project and step through to see if the event is
firing?
dkb
No the response.write is not returning anything
and no where on my page or code behind is a WithEvents statement
"Dblood" <db*********@infinitechs.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
What I mean is that when I copied your control (the text below) to an
aspx page, it didn't create the variable for me on the code-behind
page.
<asp:CustomValidator ID="checkHandicap" runat="server"
ControlToValidate="startHandicap" ErrorMessage="Handicap out of range"
OnServerValidate="checkHandicap_ServerValidate"></asp:CustomValidator>
So, I had to create that variable myself. Yours is probably already
there. Near the top of the code-behind view you'll see:
Protected WithEvents checkHandicap As CustomValidator
Any luck using the Response.write to see if the isvalid ever changes?
Can you debug the project and step through to see if the event is
firing?
dkb
Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _
System.Web.UI.WebControls.CustomValidator
and then try again.
dkb
Dblood schrieb:
Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _
System.Web.UI.WebControls.CustomValidator
and then try again.
dkb
Hey Slim. If I understand you right, I had the same problem some time
ago on the client side. In my case args.Value didn't return anything.
The event was fired, but arg.Value was empty.
My solution was to adress the textbox directly throug something like:
((TextBox)Page.FindControl("startHandicap")).Text
MfG
Georg Fleischer
"Dblood" <db*********@infinitechs.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _
System.Web.UI.WebControls.CustomValidator
and then try again.
sorry took so long to reply
It tells me that it is already declared with events, yet its not on the
page.
I assume that VS2005 hides it from view.
dkb
I have since found that no events are working in the site except for page
load, they were working until recently?
"Slim" <me@here.comwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
>
"Dblood" <db*********@infinitechs.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
>Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _ System.Web.UI.WebControls.CustomValidator
and then try again.
sorry took so long to reply
It tells me that it is already declared with events, yet its not on the
page.
I assume that VS2005 hides it from view.
>dkb
Hi Slim,
Try to add ValidateEmptyText="true" to your custom validator.
For more details read http://msdn2.microsoft.com/en-us/lib...emptytext.aspx.
Regards,
Alex.
Slim wrote:
I cant seem to get my custom validation to work. can anyone spot where i
have gone wrong
control
<asp:CustomValidator ID="checkHandicap" runat="server"
ControlToValidate="startHandicap" ErrorMessage="Handicap out of range"
OnServerValidate="checkHandicap_ServerValidate" ></asp:CustomValidator>
code behind
Protected Sub checkHandicap_ServerValidate(ByVal source As Object, ByVal
args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
checkHandicap.ServerValidate
Dim ans As Integer = Integer.Parse(args.Value)
Try
If ans -27 And ans <= 27 Then
args.IsValid = True
Exit Sub
End If
Catch exc As Exception
End Try
args.IsValid = False
End Sub
"seigo" <se******@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi Slim,
Try to add ValidateEmptyText="true" to your custom validator.
thanks but no go
For more details read http://msdn2.microsoft.com/en-us/lib...emptytext.aspx.
Regards,
Alex.
Slim wrote:
>I cant seem to get my custom validation to work. can anyone spot where i have gone wrong
control <asp:CustomValidator ID="checkHandicap" runat="server" ControlToValidate="startHandicap" ErrorMessage="Handicap out of range" OnServerValidate="checkHandicap_ServerValidate" ></asp:CustomValidator> code behind
Protected Sub checkHandicap_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles checkHandicap.ServerValidate
Dim ans As Integer = Integer.Parse(args.Value)
Try
If ans -27 And ans <= 27 Then
args.IsValid = True
Exit Sub
End If
Catch exc As Exception
End Try
args.IsValid = False
End Sub
"Slim" <me@here.comwrote in message
news:OO**************@TK2MSFTNGP02.phx.gbl...
>I have since found that no events are working in the site except for page load, they were working until recently?
sorry false alarm, its only that page, event a simple button on click event
will not work on the page.
I have recreated a new page with new code behind page, and when I copy html
and controls I have the same problems
>
"Slim" <me@here.comwrote in message
news:eT**************@TK2MSFTNGP04.phx.gbl...
>> "Dblood" <db*********@infinitechs.comwrote in message news:11**********************@p79g2000cwp.googleg roups.com...
>>Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _ System.Web.UI.WebControls.CustomValidator
and then try again. sorry took so long to reply
It tells me that it is already declared with events, yet its not on the page.
I assume that VS2005 hides it from view.
>>dkb
Sorry to waste your time
I found that I had to make sure the all other required validation controls
were satisfied before custom validation would work.
after pulling my hair out for days, I calmed down took a deep breath and had
a logical look at my code,
thanks for your time
"Slim" <me@here.comwrote in message
news:ev**************@TK2MSFTNGP04.phx.gbl...
>
"Slim" <me@here.comwrote in message
news:OO**************@TK2MSFTNGP02.phx.gbl...
>>I have since found that no events are working in the site except for page load, they were working until recently?
sorry false alarm, its only that page, event a simple button on click
event will not work on the page.
I have recreated a new page with new code behind page, and when I copy
html and controls I have the same problems
>>
"Slim" <me@here.comwrote in message news:eT**************@TK2MSFTNGP04.phx.gbl...
>>> "Dblood" <db*********@infinitechs.comwrote in message news:11**********************@p79g2000cwp.google groups.com... Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _ System.Web.UI.WebControls.CustomValidator
and then try again.
sorry took so long to reply
It tells me that it is already declared with events, yet its not on the page.
I assume that VS2005 hides it from view.
dkb This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Barbara Alderton |
last post by:
I setup some standard Required Field Validation controls and one Custom
validation control on an ASP.NET page (within a user control) to validate
text entry. I also setup a Summary Control to post...
|
by: Stephen Adam |
last post by:
Hi there,
I have written a custom validation control which checks to see of an input
field is not empty and contains only numeric data. I was using a regular
expression validation control but...
|
by: |
last post by:
Hi all,
Has anyone been able to write some custom javascript on the onclick event of
submit button to do certain things like disable submit button, only submit
form once etc. This was a breeze...
|
by: wardy1975 |
last post by:
Hi All,
Looking for a little expert advice on a few web standards issues. I am
currently trying to understand the impact of web standards for a web
application I work with. I have been doing a...
|
by: Marek |
last post by:
Hi all,
I have custrom control with four elements: text box, regular expression
validator, required field validator and custom validator. Next this control
is dragged on to web site with several...
|
by: Andy |
last post by:
Hi folks,
I have a customvalidator control that works properly if it isn't
contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I
find that _ServerValidate doesn't get fired,...
|
by: gagandeepgupta16 |
last post by:
Hi
I am working on an entry form using validation controls in ASP.NET.
I have two controls which requires custom validators, no issue in using plain custom validators.
But when i am using...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: asharda |
last post by:
I have a custom property grid. I am using custom property grid as I do
not want the error messages that the propertygrid shows when abphabets
are entered in interger fields.
The custom property...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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: 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...
| |