Fixed Validating Date Less than Today using DOTNET

To Validate Date entered by user to check wether it is
“Less than Todays Date”

we can use Compare field validator like this

 <asp:CompareValidator ID=”CompareValidator1″ runat=”server” ControlToValidate=”Date_Txtbox”
Display=”Dynamic” ErrorMessage=”Date Should not be Greater than Today” Type=”Date”
ValueToCompare = ‘<%#DateTime.Today.ToShortDateString()%>’ Operator=”LessThan” ></asp:CompareValidator>

and one should add

Page.DataBind() code in Page_Load method of a page

if you didnt wrote Page.DataBind() in page load it will give the following error

Cannot convert String to Date

Advertisements

About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Articles, Programming and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s