473,383 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

User input date Validating

Hi,

I'm trying to validate user input date using range validator on a text box .
This code is throwing this exception

"The value 'DateTime.Now;' of the MaximumValue property of 'rvQDate' cannot
be converted to type 'Date'. "

<asp:TextBox ID="txtQDate" runat="server" Enabled="False"></asp:TextBox>

<asp:Image ID="iQDate" runat="server" ImageUrl="~/images/Calendar.png"
Visible="False" />

<cc1:CalendarExtender ID="calQDate" runat="server" BehaviorID="calQDate"
TargetControlID="txtQDate" PopupButtonID="iQDate" Format="dd/MM/yyyy">

</cc1:CalendarExtender>

<asp:RangeValidator ID="rvQDate" runat="server" ControlToValidate="txtQDate"
Display="Dynamic"

ErrorMessage="Invalid QDate." MaximumValue="DateTime.Now;" Type="Date"
CultureInvariantValues="True">*</asp:RangeValidator>

How can I solve this ?
Nov 12 '07 #1
1 4937
Tamer Ibrahim wrote:
Hi,

I'm trying to validate user input date using range validator on a
text box . This code is throwing this exception

"The value 'DateTime.Now;' of the MaximumValue property of 'rvQDate'
cannot be converted to type 'Date'. "

<asp:TextBox ID="txtQDate" runat="server"
Enabled="False"></asp:TextBox>
<asp:Image ID="iQDate" runat="server" ImageUrl="~/images/Calendar.png"
Visible="False" />

<cc1:CalendarExtender ID="calQDate" runat="server"
BehaviorID="calQDate" TargetControlID="txtQDate"
PopupButtonID="iQDate" Format="dd/MM/yyyy">
</cc1:CalendarExtender>

<asp:RangeValidator ID="rvQDate" runat="server"
ControlToValidate="txtQDate" Display="Dynamic"

ErrorMessage="Invalid QDate." MaximumValue="DateTime.Now;" Type="Date"
CultureInvariantValues="True">*</asp:RangeValidator>

How can I solve this ?
You can not set the MaximumValue="DateTime.Now" like that (declaratively).
This will cause the value to be set to the literal string value, which
throws an error.

You can set it programmatically, though.
Leave the MaximumValue empty, and add this line to the Page_Load event:
rvQDate.MaximumValue=DateTime.Now

--

Riki
Nov 12 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
6
by: Hoschi-Ingo | last post by:
Hello NG, I want to write a generic function to validate data in input items. For this I want to pass a refernce to the object which calls this function to read out the and modify it if...
5
by: sourabh | last post by:
Hi I have a basic qus. I am writing a middle-tier component. I have constructor which takes 3 inputs, here's how it looks internal ClassName(Database dbToUse, Int64 pk,DateTime Date) { } ...
1
by: panche | last post by:
I'm developing a fairly simple user control that has two textboxes for date/time entry (a from date/time and a to date/time). One of my requirements is that there should be no button that sets...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
9
by: chuck | last post by:
I need some help with validating user input. I am writing a C computer program for an intro to C course. Here is the situation. I am creating an application that will do currency conversions. ...
2
by: MadMike42 | last post by:
This is really starting to annoy me, I've got a form, that has some input boxes, a example of the code is here:- <form action="admin_save_stock.asp" method="post" name="MyFormData"> <input...
4
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating...
3
by: William Gill | last post by:
I have decided that Since I have to update the processing on many of my forms, I'm going to start them all over from scratch. Before I begin I thought I'd solicit comments on using the PHP regex...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.