Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Runtime validation Webcontrol

Reply
Thread Tools

Runtime validation Webcontrol

 
 
brandonjack007@gmail.com
Guest
Posts: n/a
 
      07-31-2007
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.

 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      07-31-2007
* http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      07-31-2007
* (E-Mail Removed) 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
 
Reply With Quote
 
brandonjack007@gmail.com
Guest
Posts: n/a
 
      08-01-2007
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;
}
}


 
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
Runtime Validation WebControl brandonjack007@gmail.com ASP .Net Web Controls 0 07-25-2007 11:24 PM
Custom webcontrol that references another webcontrol Fabricio ASP .Net Building Controls 0 09-21-2005 02:55 AM
Trapping an Exception ocurring in a Webcontrol at the Page or parent WebControl level. ASP .Net 2 01-31-2005 06:34 PM
WebControl inside of WebControl and attaching events Kasabaarde Sumta ASP .Net Building Controls 0 12-13-2004 09:51 PM
Can a webcontrol (webcontrol.dll) have a configuration file? Luis Ramírez. ASP .Net Building Controls 2 07-06-2004 04:35 PM



Advertisments