Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem with CustomValidator

Reply
Thread Tools

Problem with CustomValidator

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-18-2005
I want to make sure that the SelectedDate property of the Calendar control
is later than the current date or that a certain checkbox is selected. I
tried to use a CustomValidator control with the following code:

Private Sub validTimeFrame_ServerValidate(ByVal source As System.Object,
ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
validTimeFrame.ServerValidate

If chkUnknown.Checked OrElse calTimeFrame.SelectedDate >= Date.Today Then

args.IsValid = True

Else

args.IsValid = False

End If

End Sub


As you can see, I check to see if chkUnknown is checked or if
calTimeFrame.SelectedDate>= Date.Today. If either one is true, then I assign
True to the IsValid property, otherwise I assign it a value of false.
However, when I test the page it brings up the following error:

[HttpException (0x80004005): Control 'calTimeFrame' referenced by the
ControlToValidate property of 'validTimeFrame' cannot be validated.]
System.Web.UI.WebControls.BaseValidator.CheckContr olValidationProperty(String
name, String propertyName)
System.Web.UI.WebControls.CustomValidator.ControlP ropertiesValid()
System.Web.UI.WebControls.BaseValidator.get_Proper tiesValid()
System.Web.UI.WebControls.BaseValidator.Render(Htm lTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
writer)
System.Web.UI.WebControls.TableCell.RenderContents (HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.WebControls.Table.RenderContents(Htm lTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlContainerControl.Re nder(HtmlTextWriter
writer)
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()

Because this tells me nothing more than that the control cannot be
validated, I do not know where to start. Any ideas? Thanks.
--
Nathan Sokalski

http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      06-18-2005
With a CustomValidator you don't need to assign the ControlToValidate property.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> I want to make sure that the SelectedDate property of the Calendar
> control is later than the current date or that a certain checkbox is
> selected. I tried to use a CustomValidator control with the following
> code:
>
> Private Sub validTimeFrame_ServerValidate(ByVal source As
> System.Object, ByVal args As
> System.Web.UI.WebControls.ServerValidateEventArgs) Handles
> validTimeFrame.ServerValidate
>
> If chkUnknown.Checked OrElse calTimeFrame.SelectedDate >= Date.Today
> Then
>
> args.IsValid = True
>
> Else
>
> args.IsValid = False
>
> End If
>
> End Sub
>
> As you can see, I check to see if chkUnknown is checked or if
> calTimeFrame.SelectedDate>= Date.Today. If either one is true, then I
> assign True to the IsValid property, otherwise I assign it a value of
> false. However, when I test the page it brings up the following error:
>
> [HttpException (0x80004005): Control 'calTimeFrame' referenced by the
> ControlToValidate property of 'validTimeFrame' cannot be validated.]
>
> System.Web.UI.WebControls.BaseValidator.CheckContr olValidationProperty
> (String
> name, String propertyName)
> System.Web.UI.WebControls.CustomValidator.ControlP ropertiesValid()
> System.Web.UI.WebControls.BaseValidator.get_Proper tiesValid()
> System.Web.UI.WebControls.BaseValidator.Render(Htm lTextWriter
> writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
> System.Web.UI.Control.Render(HtmlTextWriter writer)
> System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
> writer)
> System.Web.UI.WebControls.TableCell.RenderContents (HtmlTextWriter
> writer)
> System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
> System.Web.UI.Control.Render(HtmlTextWriter writer)
> System.Web.UI.WebControls.WebControl.RenderContent s(HtmlTextWriter
> writer)
> System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.WebControls.Table.RenderContents(Htm lTextWriter
> writer)
> System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
> System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
> writer)
>
> System.Web.UI.HtmlControls.HtmlContainerControl.Re nder(HtmlTextWriter
> writer)
> System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
> System.Web.UI.Control.Render(HtmlTextWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
> System.Web.UI.Page.ProcessRequestMain()
> Because this tells me nothing more than that the control cannot be
> validated, I do not know where to start. Any ideas? Thanks.
>




 
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
newbie: Problem with CustomValidator Jeff ASP .Net 2 02-08-2007 04:22 PM
A CustomValidator Problem, I don't understand the logic antonyliu2002@yahoo.com ASP .Net 0 10-14-2005 05:58 PM
Problem with CustomValidator Nathan Sokalski ASP .Net 1 06-18-2005 02:48 AM
customvalidator problem in datagrid philipl@vistatec.ie ASP .Net 3 06-04-2004 03:48 PM
customvalidator problem bill yeager ASP .Net 1 08-28-2003 03:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57