asp.net.netwebformsservercontrols

How do you insert a newline character within the RegularExpressionValidator ErrorMessage Field?


Consider this code below:

<asp:RegularExpressionValidator 
        ID="MyTestId"  
        ValidationGroup="MyTestGroup" 
        ErrorMessage="You are a silly user. You entered the wrong format for this problem. Please try again. Using this format! ELRLDKX##Z"
        ValidationExpression="some unrelated regex"
        runat="server"
        ControlToValidate="MyTestTextbox">
</asp:RegularExpressionValidator> 

Is there a way to insert an escape character of some sort into the ErrorMessage string to ensure that Please try again. Using this format! ELRLDKX##Z is on another line? I have tried, \n with no luck.


Solution

  • The Validator is on a web page, so you can just add html code to the text, like a <br />

    ErrorMessage="You are a silly user. You entered the wrong format for this problem.<br />Please try again. Using this format! ELRLDKX##Z"