Chris D wrote:
Hi Goran & thanks for helping. This is what I have ...
protected void Page_Load(object sender, EventArgs e)
{
DateTime theDate, maxDate, minDate;
theDate = DateTime.Parse(DateTime.Now);
The DateTime.Now property returns a DateTime value, so you should not
parse it. By doing so you force an implicit conversion to string, which
you then parse into a DateTime value identical to the one that
DateTime.Now returned.
theDate = DateTime.Now.
However, for your application the time is irrelevant, so you would
rather use the Today property:
theDate = DateTime.Today;
minDate = theDate.AddYears(-65);
maxDate = theDate.AddYears(-10);
}
And this in the aspx
<asp:TextBox ID="tbDOBchk" runat="server"></asp:TextBox>
<asp:RangeValidator ID="rvDOBchk" Type="Date" runat="server"
ControlToValidate="tbDOBchk" ErrorMessage="RangeValidator"
MaximumValue="maxDate"
MinimumValue="minDate">message</asp:RangeValidator>
You can't use variable names as property values. The control parses the
arguments, it doesn't evaluate them.
You should set the arguments from the Page_Load method:
rvDOBchk.MinimumValue = minDate;
rvDOBchk.MAximumValue = maxDate;
--
Göran Andersson
_____
http://www.guffa.com