473,503 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with CustomValidator

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
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
1 1489
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.


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2008
by: bill yeager | last post by:
I'm using the customvalidator in my web page. I get the following error when I try to run the web page: Unable to find control id 'lstRider' referenced by the 'ControlToValidate' property of...
3
1842
by: philipl | last post by:
hi, i have a textbox in my edititemtemplate in my datagrid. I have created a customvalidator for it, when i update the row the appropiate function gets called to customvalidate but the problem...
10
3063
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page...
1
1811
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
0
3525
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
0
1252
by: antonyliu2002 | last post by:
The full code is pasted below. It looks scarily long, but it's pretty simple. It is adapted from a sample code at MSDN. If you run it, and check it out from your browser, you'll see: ...
0
2165
by: bauer.todd | last post by:
The following page works fine on FireFox (the custom validator checks to make sure that there's a value in the file upload text box). However, on IE 7, when there's a value in the text box, the...
2
1951
by: Jeff | last post by:
hey net 3.5 I have problem with a customvalidator. I enter values into the TextBox named "txt" and clicks on the save button (ibSave) then the TestValidate method get triggered. TestValidate...
2
1326
by: testemailsystem.test | last post by:
Hi everyone, I use CustomValidator with the server event onservervalidate (no javascript event). The scenario : The user filled the form and pressed SUBMIT. But because there was an error –...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.