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 14 2673
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*********@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
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
"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
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
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
Slim,
Add this to your code behind then,
Protected WithEvents checkHandicap As _
System.Web.UI.W ebControls.Cust omValidator
and then try again.
dkb
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
"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 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 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 get the custom
validation message to show up if invalid.
So far I have the summary control...
|
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 requirement and will display a error message if it doesnt,
it wont stop it from being used and sent to my...
|
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 was done and was successful. Any ideas?
TIA!
|
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 level compliance.
Ideally, I would like to be at XHTML 1.0 Strict.
However, in my reading I have...
|
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 validation. When this push button is
removed from validation group then custom validation runs ok but...
| |
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:
cvCustomValidator_ServerValidate(object source,
system.Web.UI.WebControls.ServerValidateEventArgs args) <== doesn't get
|
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 validation callout extender :-
http://www.junnark.com/Articles/Article0001.aspx
I searched a lot but...
|
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 words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
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 comes up.
If I say CustomPropertyGrid p = new CustomPropertyGrid();
p.SelectedObject = new...
|
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 words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |