Using customvalidator control in asp.net 1.1

Discussion in 'ASP .Net' started by settyv@gmail.com, Oct 26, 2006.

  1. Guest

    Hi,

    I need to use customvalidator control for calculating datedifference
    and need to alert if fromdate is greater than todate.Please let me know
    how can i do that using this control in asp.net.


    Thanks in advance,
    Vishnu
    , Oct 26, 2006
    #1
    1. Advertising

  2. Vishnu,

    Simply handle the ServerValidate method on the CustomValidator control.
    Normally the property for ControlToValidate would be pointing to the
    TextBox holding the value you want to check.

    However, you want to compare values from 2 controls. There is no
    reason you cannot directly refer to the related controls in your event
    handler.

    Protected Sub cvCompareDates_ServerValidate(ByVal source As Object, _
    ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) _
    Handles cvCompareDates.ServerValidate
    Dim fromDate as String = tbFromDate.Text
    Dim toDate as String = tbToDate.Text
    If (IsDate(fromDate) AndAlso IsDate(toDate)) Then
    args.IsValid = CDate(toDate) < CDate(fromDate)
    End If
    End Sub

    Then you can check Page.IsValid and cvCompareDates.IsValid and trigger
    the actions you want to take as appropriate.

    Brennan Stehling
    http://brennan.offwhite.net/blog/

    wrote:
    > Hi,
    >
    > I need to use customvalidator control for calculating datedifference
    > and need to alert if fromdate is greater than todate.Please let me know
    > how can i do that using this control in asp.net.
    >
    >
    > Thanks in advance,
    > Vishnu
    Brennan Stehling, Oct 26, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Heavey

    CustomValidator Control

    Jim Heavey, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    342
  2. =?Utf-8?B?Vmk=?=

    CustomValidator Control

    =?Utf-8?B?Vmk=?=, Oct 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    360
    Scott Allen
    Oct 21, 2004
  3. Dan Sikorsky
    Replies:
    1
    Views:
    5,854
    Dan Sikorsky
    Feb 17, 2005
  4. theresa
    Replies:
    1
    Views:
    552
    =?Utf-8?B?bXVzb3NkZXY=?=
    Jun 26, 2006
  5. Richard
    Replies:
    2
    Views:
    4,350
    theacadian
    Mar 3, 2011
Loading...

Share This Page