Solved

CompareValidator error message

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net Report Printing Issue 3 31
C# Object Reference is Required for the non-static field, method, or property 10 32
C# bracket error 3 30
.NET 2008 VB and C# 6 27
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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