Solved

CompareValidator error message

Posted on 2013-12-04
3
250 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

13 Experts available now in Live!

Get 1:1 Help Now