Runtime validation Webcontrol

Discussion in 'ASP .Net Web Controls' started by brandonjack007@gmail.com, Jul 31, 2007.

  1. Guest

    I have a webcontrol that extends from
    System.Web.UI.WebControls.WebControl. It has 3 properties
    SelectedDate, MaximumDate,MinimumDate. During design time I use
    ArgumentException to ensure
    MinimumDate<SelectedDate<MaximumDate. How can I achieve this
    validation during runtime.
    , Jul 31, 2007
    #1
    1. Advertising

  2. * wrote, On 31-7-2007 22:24:
    > I have a webcontrol that extends from
    > System.Web.UI.WebControls.WebControl. It has 3 properties
    > SelectedDate, MaximumDate,MinimumDate. During design time I use
    > ArgumentException to ensure
    > MinimumDate<SelectedDate<MaximumDate. How can I achieve this
    > validation during runtime.
    >


    You can add a range validator to the user control. set it's minimum
    value and maximumvalue and the control to validate and you're all set.

    Jesse
    Jesse Houwing, Jul 31, 2007
    #2
    1. Advertising

  3. * wrote, On 31-7-2007 22:24:
    > I have a webcontrol that extends from
    > System.Web.UI.WebControls.WebControl. It has 3 properties
    > SelectedDate, MaximumDate,MinimumDate. During design time I use
    > ArgumentException to ensure
    > MinimumDate<SelectedDate<MaximumDate. How can I achieve this
    > validation during runtime.
    >


    I was too fast in answering I see now. You're inheriting from
    WebControl, not WebUserControl.

    In that case you need to implement the IValidator interface and provide
    the correct validation details in there.

    Jesse
    Jesse Houwing, Jul 31, 2007
    #3
  4. Guest

    I implement IValidator interface in the control
    Is this the correct way cos it fails....
    public bool IsValid
    {
    get {return mIsValid;}
    set { mIsValid = value;}
    }

    public string ErrorMessage
    {
    get { return mErrorMessage; }
    set { mErrorMessage = value; }
    }

    public virtual void Validate()
    {
    this.IsValid = true;
    if(!IsDate(this.selectedDate.ToString()))
    {
    this.IsValid = false;
    }
    if (this.selectedDate<this.MinimumDate ||
    this.selectedDate>this.MaximumDate)
    {
    this.IsValid = false;
    }
    }
    , Aug 1, 2007
    #4
    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. Guest
    Replies:
    2
    Views:
    723
  2. Luis Ramírez.

    Can a webcontrol (webcontrol.dll) have a configuration file?

    Luis Ramírez., Jul 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    181
    Luis Ramírez
    Jul 6, 2004
  3. Kasabaarde Sumta

    WebControl inside of WebControl and attaching events

    Kasabaarde Sumta, Dec 13, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    174
    Kasabaarde Sumta
    Dec 13, 2004
  4. Fabricio

    Custom webcontrol that references another webcontrol

    Fabricio, Sep 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    166
    Fabricio
    Sep 21, 2005
  5. Runtime Validation WebControl

    , Jul 26, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    96
Loading...

Share This Page