Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Custom Validator newbie question

Reply
Thread Tools

Custom Validator newbie question

 
 
MattB
Guest
Posts: n/a
 
      11-23-2004
Hi. I've looked at a couple of examples and I thought I had a handle on
this, but it's not working like I expected.

I created a custom validator on my form that (for now) only has a server
side check that performs a luhn check on a credit card number. I've created
the validator, and the server side code to check the card number. The
problem is, I can enter invalid numbers and the validator never seems to do
anything - the numbers are accepted like there's no problem.

In stepping through this in the debugger, I see my validation sub execute,
and args.IsValid evaluates to false, but then I see no indication of this on
the page, like the validator never hears back from the sub I created.

Any ideas what I've done wrong? Thanks!

Matt


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      11-23-2004
Hi,

in the logic that is dependable on the validator, do you check Page.IsValid
or validator.IsValid before letting that code run? You need to check that
manually at server-side to ensure that validion is enforced.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsider
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


"MattB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi. I've looked at a couple of examples and I thought I had a handle on
> this, but it's not working like I expected.
>
> I created a custom validator on my form that (for now) only has a server
> side check that performs a luhn check on a credit card number. I've

created
> the validator, and the server side code to check the card number. The
> problem is, I can enter invalid numbers and the validator never seems to

do
> anything - the numbers are accepted like there's no problem.
>
> In stepping through this in the debugger, I see my validation sub execute,
> and args.IsValid evaluates to false, but then I see no indication of this

on
> the page, like the validator never hears back from the sub I created.
>
> Any ideas what I've done wrong? Thanks!
>
> Matt
>
>



 
Reply With Quote
 
 
 
 
MattB
Guest
Posts: n/a
 
      11-23-2004
I don't check those, but the other validators on the page work fine. They
are not custom (regex, compare, required field).
So even if those work ok, would this make my custom validator not work?
Thanks!

Teemu Keiski wrote:
> Hi,
>
> in the logic that is dependable on the validator, do you check
> Page.IsValid or validator.IsValid before letting that code run? You
> need to check that manually at server-side to ensure that validion is
> enforced.
>
>
> "MattB" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi. I've looked at a couple of examples and I thought I had a handle
>> on this, but it's not working like I expected.
>>
>> I created a custom validator on my form that (for now) only has a
>> server side check that performs a luhn check on a credit card
>> number. I've created the validator, and the server side code to
>> check the card number. The problem is, I can enter invalid numbers
>> and the validator never seems to do anything - the numbers are
>> accepted like there's no problem.
>>
>> In stepping through this in the debugger, I see my validation sub
>> execute, and args.IsValid evaluates to false, but then I see no
>> indication of this on the page, like the validator never hears back
>> from the sub I created.
>>
>> Any ideas what I've done wrong? Thanks!
>>
>> Matt



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      11-23-2004
If those other validators use client-side validation (in IE they do by
default) they prevent the postback on error scenarios, so that already
prevents the server-side code from running (even if your custom validator
would be OK) as validation goes all-or-nothing with the page.

To be safe for other browsers than IE, you need to check Page.IsValid or
validator.IsValid (depending on your situation if you want to overcome the
whole-page validation limitation) always when you have validators on the
page. Also to turn the aspect, writing only server-side check wires the
validation only when postback happens, so with such validator client-side
checks won't happen so Page:IsValid is your only way (buolt-in validation
controls work only at server.side for non-IE browsers)

Just to say that there's also a good commercial validation product on the
market, Peter Blum's Professional Validation And More, if you might be in
need for such. http://www.peterblum.com/VAM/Home.aspx It overcomes many
limitations that built-in ASp.NET validation controls have.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsider
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke


"MattB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I don't check those, but the other validators on the page work fine. They
> are not custom (regex, compare, required field).
> So even if those work ok, would this make my custom validator not work?
> Thanks!
>
> Teemu Keiski wrote:
> > Hi,
> >
> > in the logic that is dependable on the validator, do you check
> > Page.IsValid or validator.IsValid before letting that code run? You
> > need to check that manually at server-side to ensure that validion is
> > enforced.
> >
> >
> > "MattB" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> Hi. I've looked at a couple of examples and I thought I had a handle
> >> on this, but it's not working like I expected.
> >>
> >> I created a custom validator on my form that (for now) only has a
> >> server side check that performs a luhn check on a credit card
> >> number. I've created the validator, and the server side code to
> >> check the card number. The problem is, I can enter invalid numbers
> >> and the validator never seems to do anything - the numbers are
> >> accepted like there's no problem.
> >>
> >> In stepping through this in the debugger, I see my validation sub
> >> execute, and args.IsValid evaluates to false, but then I see no
> >> indication of this on the page, like the validator never hears back
> >> from the sub I created.
> >>
> >> Any ideas what I've done wrong? Thanks!
> >>
> >> Matt

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM
Newbie mistake or Custom Validator bug? =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= ASP .Net 2 02-23-2006 06:00 PM
Question about custom validator on UserControl. Ken Varn ASP .Net 1 11-02-2004 05:40 PM
Custom Validator Control - newbie Angela ASP .Net 5 07-26-2004 03:53 PM
How to get custom control to work with custom validator Scott Yenor ASP .Net Web Controls 0 01-27-2004 12:37 AM



Advertisments