Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

asp:validators and Content Between Tags

In the application I have taken over all the validators have their error message in the ErrorMessage attribute of the validator and also in between the open and close tags (identical text).  Is there any advantage to doing it like this because I don't really want to have to update all error messages in two places?


<asp:validator ErrorMessage="That's not right">That's not right</asp:validator>

I want to replace with:

<asp:validator ErrorMessage="That's not right"/>

My replacement seems to work but I'm wary of breaking something!



Thomas David Baker
Tuesday, July 22, 2003

There are two properties at play -- ErrorMessage and Text. The Text property is what you're seeing inbetween the tags. The difference is apparent when you use a ValidationSummary control to summarise error in one place. In this case the ValidationSummary will show the ErrorMessage and the control will diaply the Text property. The idea is that I could set the Text property to "*" so that a asterisk appears next to the offending control and the full ErrorMessage appears in the ValidationSummary.

Duncan Smart
Tuesday, July 22, 2003

*  Recent Topics

*  Fog Creek Home