Hi,
For example, what I did was set:
<asp:comparevalidator id="cvEndDate" style="Z-INDEX: 229; LEFT: 592px; POSITION: absolute; TOP: 1896px"
runat="server" Font-Names="Arial" Font-Size="X-Small"
ControlToValidate="txtEndDate"
ErrorMessage="End Date must be after start date" Type="Date" Operator="GreaterThan"
ControlToCompare="txtStartDate">
End Date must be after start date
</asp:comparevalidator>
in Page_Load:
StartDateCalendar.SelectedDate = StartDateCalendar.TodaysDate;
EndDateCalendar.SelectedDate = StartDateCalendar.SelectedDate.AddYears(1).AddDays (-1); //my default end
date was one year and a day less than my start date
txtCurrDate.Text = DateTime.Now.ToShortDateString();
txtStartDate.Text = StartDateCalendar.SelectedDate.ToShortDateString() ;
txtEndDate.Text = EndDateCalendar.SelectedDate.ToShortDateString();
and everytime, the calendar control (or whatever you have that causes the date to change) has a
selectedIndexChanged 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)
{
DateTimeFormatInfo fi = new DateTimeFormatInfo();
fi = DateTimeFormatInfo.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*****@discussions.microsoft.com> wrote in message
news:6C**********************************@microso ft.com...I tried this but got the following error.
Cannot implicitly convert type 'System.DateTime' 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
{
CompareValidator1.ValueToCompare = DateTime.Now;
}
cheers,
mortb
"Stephen" <St*****@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.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:CompareValidator id="CompareValidator1" style="Z-INDEX: 103; LEFT:
> 431px; POSITION: absolute; TOP: 277px" runat="server"
> ErrorMessage="CompareValidator" ControlToValidate="TextBox2"
> Type="Date"
> Operator="GreaterThanEqual"
> ValueToCompare="now()"></asp:CompareValidator>