Solved

CompareValidator error message

Posted on 2013-12-04
3
253 Views
Last Modified: 2013-12-19
how can I automatically set ErrorMessage text to whatever is in the ValueToCompare?
a bit like Please enter a date less than {0} type of thing?

I change ValueToCompare in code-behind, does ErrorMessage need changed in code-behind too or can I use something like {0} ?



            <asp:CompareValidator
                ID="dateValidator" runat="server"
                Type="Date"
                ValueToCompare="30/11/2013"
                Operator="LessThanEqual"
                ControlToValidate="txtDateEnd"
                ErrorMessage="Please enter a date less than 30/11/2013 "></asp:CompareValidator>
0
Comment
Question by:rwallacej
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 39697428
I think the only way to do this will be to update the errormessage from the code behind at the same time as you update the ValueToCompare that will ensure consistency and is the only way possible afaik.

Does the date have any relevance is it always today's date or end of month date?

If it is todays date then there may be a way to do it in the markup or you could just change the message to be more generic such as 'Please enter a date before today' or 'Please enter a date before month end'.
0
 

Author Comment

by:rwallacej
ID: 39698735
Does the date have any relevance is it always today's date or end of month date?
- no
0
 

Author Closing Comment

by:rwallacej
ID: 39729648
Wrote code to set the values in code behind as can't be automated
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now