I created a custom textbox control that has a textbox for the user to enter a date, but when the user clicks on the textbox, a calendar picker pops up. It lives in a ascx file, and it supposed to be re-usable - right?
Ok, so now I drop two of them on my aspx page so that the user can pick a "from date" and a "to date". But I need to validate so that the user can't pick something like:
From: 4/16/08 To: 3/16/07
The problem is that ASP.NET I does not find them, throwing the error Unable to find control id 'tctl00$cphMenu3$calFromDate$txtFromDate' referenced by the 'ControlToValidate' property of 'cvCheckDates'.
Here is my aspx page:
and in my VB, I'm trying to do this:
which worked fine when I added onClick attributes for javascript - but what in blazes is the deal with the compare validator? i've searched around and seen some posts that say that this is not easily possible, that can't be true can it? If so then is the workaround having to write a JavaScript data validator script from scratch?
Ok, so now I drop two of them on my aspx page so that the user can pick a "from date" and a "to date". But I need to validate so that the user can't pick something like:
From: 4/16/08 To: 3/16/07
The problem is that ASP.NET I does not find them, throwing the error Unable to find control id 'tctl00$cphMenu3$calFromDate$txtFromDate' referenced by the 'ControlToValidate' property of 'cvCheckDates'.
Here is my aspx page:
Code:
<div>
<asp:ScriptManager id="scrmanScriptManager" runat="server"/>
<AJAXExtensions:UpdatePanel ID="upanCalendarPicker" runat="server">
<ContentTemplate>
<slcCustomControl:DVDatePicker id="calFromDate" runat="server"/>
<slcCustomControl:DVDatePicker id="calToDate" runat="server"/>
<asp:CheckBox ID="chkAny" runat="server" Checked="True" ToolTip="Chooses All Dates" AutoPostBack="True" OnCheckedChanged="chkAny_CheckedChanged" />
<asp:CompareValidator ID="cvCheckDates" runat="server" ErrorMessage="You Doofus">You Doofus</asp:CompareValidator>
</ContentTemplate>
</AJAXExtensions:UpdatePanel>
</div>
and in my VB, I'm trying to do this:
Code:
Dim txtFromDate As TextBox = Me.calFromDate.FindControl("txtFromDate")
Dim txtToDate As TextBox = Me.calToDate.FindControl("txtFromDate")
Dim cv As CompareValidator = Me.cvCheckDates
cv.ControlToValidate = txtToDate.ClientID
cv.ControlToCompare = txtFromDate.ClientID
cv.Type = ValidationDataType.Date
cv.Operator = ValidationCompareOperator.GreaterThan
which worked fine when I added onClick attributes for javascript - but what in blazes is the deal with the compare validator? i've searched around and seen some posts that say that this is not easily possible, that can't be true can it? If so then is the workaround having to write a JavaScript data validator script from scratch?