Hi,
For example, what I did was set:
<asp:compareval idator id="cvEndDate" style="Z-INDEX: 229; LEFT: 592px; POSITION: absolute; TOP: 1896px"
runat="server" Font-Names="Arial" Font-Size="X-Small"
ControlToValida te="txtEndDate "
ErrorMessage="E nd Date must be after start date" Type="Date" Operator="Great erThan"
ControlToCompar e="txtStartDate ">
End Date must be after start date
</asp:comparevali dator>
in Page_Load:
StartDateCalend ar.SelectedDate = StartDateCalend ar.TodaysDate;
EndDateCalendar .SelectedDate = StartDateCalend ar.SelectedDate .AddYears(1).Ad dDays(-1); //my default end
date was one year and a day less than my start date
txtCurrDate.Tex t = DateTime.Now.To ShortDateString ();
txtStartDate.Te xt = StartDateCalend ar.SelectedDate .ToShortDateStr ing();
txtEndDate.Text = EndDateCalendar .SelectedDate.T oShortDateStrin g();
and everytime, the calendar control (or whatever you have that causes the date to change) has a
selectedIndexCh anged event, you'll have to update the text boxes with the up-to-date value.
Hope that helps,
Michelle Hlaing
Microsoft Support Professional
***Disclaimer: This posting is provided "as is" with no warranties and confers no rights.***
I use the following code:
public bool Validate(string source)
{
DateTimeFormatI nfo fi = new DateTimeFormatI nfo();
fi = DateTimeFormatI nfo.CurrentInfo ;
DateTime dt = DateTime.Parse( source,fi);
return true;
}
However, this depends on the Regional Settings specified in your Control
Panel.
HTH
B Vidyadhar Joshi
"Stephen" <St*****@discus sions.microsoft .com> wrote in message
news:6C******* *************** ************@mi crosoft.com...I tried this but got the following error.
Cannot implicitly convert type 'System.DateTim e' to 'string'
Is there anyway of setting the Value to compare property in the
Javascript??
If not do you know how I get rid of this build error
"mortb" wrote:
probably you'll have to set the ValueToCompare in the code...
Page_load
{
CompareValidato r1.ValueToCompa re = DateTime.Now;
}
cheers,
mortb
"Stephen" <St*****@discus sions.microsoft .com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
> Is there any way of using a compare validator to compare a textbox to
> see
> if
> the date is greater than or equal to todays date. I want to set the
> ValueToCompare property to now(). It doesn't seem to like this is there
> any
> way around this problem
>
> <asp:CompareVal idator id="CompareVali dator1" style="Z-INDEX: 103; LEFT:
> 431px; POSITION: absolute; TOP: 277px" runat="server"
> ErrorMessage="C ompareValidator " ControlToValida te="TextBox2"
> Type="Date"
> Operator="Great erThanEqual"
> ValueToCompare= "now()"></asp:CompareVali dator>