Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Custom validator for a pair of controls

Reply
Thread Tools

Custom validator for a pair of controls

 
 
Erik Cruz
Guest
Posts: n/a
 
      07-17-2004
Hi.

I have a page that uses 4 textboxes where my user can input dates. Before
submit data, I need to test to see if the user filled at least two of these
textboxes. I can easily test this using simple javascript, but I am trying
to do this using a custom validator control. But as far as I know, the
validator tests just one control, not a pair of controls, as I need. Is it
possible to create a custom control for this situation?

TIA,
Erik Cruz


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-18-2004
Hi,

you can check multiple controls with CustomValidator. If you leave
ControlToValidate property to blank, CustomValidator runs the server-side
and client-side validation once per roundtrip (client-side before submitting
and server-side while postbacking as usual). It means the CustomValidator
isn't tied to the control and you can validate anything you want with it
(also blank controls or conditional validation). Certainly you need to refer
to the controls you validate in validion functions but that shouldn't be
hard.

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

"Erik Cruz" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi.
>
> I have a page that uses 4 textboxes where my user can input dates. Before
> submit data, I need to test to see if the user filled at least two of

these
> textboxes. I can easily test this using simple javascript, but I am trying
> to do this using a custom validator control. But as far as I know, the
> validator tests just one control, not a pair of controls, as I need. Is it
> possible to create a custom control for this situation?
>
> TIA,
> Erik Cruz
>
>



 
Reply With Quote
 
 
 
 
fritz
Guest
Posts: n/a
 
      07-19-2004
Teemu Keiski wrote:

> Hi,
>
> you can check multiple controls with CustomValidator. If you leave
> ControlToValidate property to blank, CustomValidator runs the server-side
> and client-side validation once per roundtrip (client-side before
> submitting and server-side while postbacking as usual). It means the
> CustomValidator isn't tied to the control and you can validate anything
> you want with it (also blank controls or conditional validation).
> Certainly you need to refer to the controls you validate in validion
> functions but that shouldn't be hard.
>

I am confused, is there not a problem with the label?. I thought the custom
validator used a label with a specific id.

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      07-19-2004
Are you somehow confusing validators that are done by using built-in
CustomValidator and then custom validator controls which are developed by
inheriting from BaseValidator? The built-in CustomValidator can work the way
I described (without ControlToValidate property)

Here is about the CustomValidator I was talking about:
http://msdn.microsoft.com/library/de...pplusvalid.asp


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



"fritz" <(E-Mail Removed)> wrote in message
news:kWGKc.38071$(E-Mail Removed)...
> Teemu Keiski wrote:
>
> > Hi,
> >
> > you can check multiple controls with CustomValidator. If you leave
> > ControlToValidate property to blank, CustomValidator runs the

server-side
> > and client-side validation once per roundtrip (client-side before
> > submitting and server-side while postbacking as usual). It means the
> > CustomValidator isn't tied to the control and you can validate anything
> > you want with it (also blank controls or conditional validation).
> > Certainly you need to refer to the controls you validate in validion
> > functions but that shouldn't be hard.
> >

> I am confused, is there not a problem with the label?. I thought the

custom
> validator used a label with a specific id.
>



 
Reply With Quote
 
Erik Cruz
Guest
Posts: n/a
 
      07-20-2004
Thanks Teemu, it worked

Maybe you can help me with another issue. My users type dates using the
format DD/MM/YYYY. How can I validate these dates in server-side code,
regardless of the format they are using?

Thanks again for your time.

Erik Cruz

"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> you can check multiple controls with CustomValidator. If you leave
> ControlToValidate property to blank, CustomValidator runs the server-side
> and client-side validation once per roundtrip (client-side before

submitting
> and server-side while postbacking as usual). It means the CustomValidator
> isn't tied to the control and you can validate anything you want with it
> (also blank controls or conditional validation). Certainly you need to

refer
> to the controls you validate in validion functions but that shouldn't be
> hard.
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
> http://blogs.aspadvice.com/joteke
>
> "Erik Cruz" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Hi.
> >
> > I have a page that uses 4 textboxes where my user can input dates.

Before
> > submit data, I need to test to see if the user filled at least two of

> these
> > textboxes. I can easily test this using simple javascript, but I am

trying
> > to do this using a custom validator control. But as far as I know, the
> > validator tests just one control, not a pair of controls, as I need. Is

it
> > possible to create a custom control for this situation?
> >
> > TIA,
> > Erik Cruz
> >
> >

>
>



 
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
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
Re: custom validator controls within a datagrid zlusca@gmail.com ASP .Net 0 12-28-2004 07:13 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