I have the following validation summary control in the markup:
<asp:ValidationSummary ID="vsValErrs" CssClass="errors" HeaderText="<div><%# TranslatedMessage%></div>" runat="server" />
where TranslatedMessage is a property defined in the code behind. The problem is that the validation summary control gets rendered as
<div id="vsValErrs" class="errors" style="color:Red;">
<div>
<!--[CDATA[<%# TranslatedMessage%-->
]]>
</div>
</div>
which causes the content to be rendered incorrectly, probably because the ]]> part is outside the comment block. Why does this happen?
For those who are wondering, the reason for having a div in the HeaderText attribute is because I’m using it to style the header text (using a CSS selector that selects the first div, in the errors class); it’s probably not best practice but this is the only way I’ve come up with.
Have you try by setting headertext property value in pageload event like
If translated message is not available then put it into session varible and set it to HeaderText property.