473,545 Members | 937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

custom validation

I cant seem to get my custom validation to work. can anyone spot where i
have gone wrong

control
<asp:CustomVali dator ID="checkHandic ap" runat="server"
ControlToValida te="startHandic ap" ErrorMessage="H andicap out of range"
OnServerValidat e="checkHandica p_ServerValidat e" ></asp:CustomValid ator>

code behind
Protected Sub checkHandicap_S erverValidate(B yVal source As Object, ByVal
args As System.Web.UI.W ebControls.Serv erValidateEvent Args) Handles
checkHandicap.S erverValidate

Dim ans As Integer = Integer.Parse(a rgs.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


Aug 18 '06 #1
14 2629
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

Aug 18 '06 #2
I get no error, but I get no return either,

from what tests I could do, the function was not firing

"Dblood" <db*********@in finitechs.comwr ote in message
news:11******** **************@ i42g2000cwa.goo glegroups.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

Aug 18 '06 #3
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_S erverValidate 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

Aug 18 '06 #4

"Dblood" <db*********@in finitechs.comwr ote in message
news:11******** *************@m 79g2000cwm.goog legroups.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_S erverValidate 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

Aug 18 '06 #5
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:CustomVali dator ID="checkHandic ap" runat="server"
ControlToValida te="startHandic ap" ErrorMessage="H andicap out of range"
OnServerValidat e="checkHandica p_ServerValidat e"></asp:CustomValid ator>

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

Aug 18 '06 #6
No the response.write is not returning anything

and no where on my page or code behind is a WithEvents statement
"Dblood" <db*********@in finitechs.comwr ote in message
news:11******** *************@7 4g2000cwt.googl egroups.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:CustomVali dator ID="checkHandic ap" runat="server"
ControlToValida te="startHandic ap" ErrorMessage="H andicap out of range"
OnServerValidat e="checkHandica p_ServerValidat e"></asp:CustomValid ator>

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

Aug 19 '06 #7
Slim,

Add this to your code behind then,

Protected WithEvents checkHandicap As _
System.Web.UI.W ebControls.Cust omValidator
and then try again.

dkb

Aug 21 '06 #8

Dblood schrieb:
Slim,

Add this to your code behind then,

Protected WithEvents checkHandicap As _
System.Web.UI.W ebControls.Cust omValidator
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("st artHandicap")). Text

MfG
Georg Fleischer

Aug 22 '06 #9

"Dblood" <db*********@in finitechs.comwr ote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Slim,

Add this to your code behind then,

Protected WithEvents checkHandicap As _
System.Web.UI.W ebControls.Cust omValidator
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

Aug 24 '06 #10

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

Similar topics

2
3709
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 all the messages to a message box (ShowMessageBox=true). The required field validation error messages show up in the summary just fine but I can't...
1
2418
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 was unable to get it fail if a field was blank. My problem now is that while my custom validation control will detect if a field matches my...
5
2630
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 in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation...
9
3126
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 lot of research in the areas of XHTML and WAI compliance, and am attempting to come up with a recommendation for our product in terms of standards...
0
1043
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 controls. All controls has the same validation group. When I press button for this validation group then all validations runs ok except custom...
3
8235
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, even if I force the customvalidator to validate by invoking its validate() method after a button is clicked: ...
1
3775
gagandeepgupta16
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 Validation Callout Extender with the custom validators its not working properly. here is the link where i got solution for one custom validator with...
2
19415
hyperpau
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
1
4369
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 grid doesn't show colloections i.e. if I have a List<Objectthen the Collection is shown but when I click on the "..." button next to it nothing...
0
2897
hyperpau
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
7656
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. ...
0
7807
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...
0
7756
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...
0
5971
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...
1
5326
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...
0
3450
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...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
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
0
703
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.