I’m working on small web form,in C#/ASP.NET. I want to store the errors messages into variables of C# class; something like this:
public static class ErrorMessages {
public static string fooX = "baa";
// etc..
}
And then concat it in some attribute of an ASP tag:
<asp:RegularExpressionValidator runat="server"
ControlToValidate="baain"
ErrorMessage= *ErrorMessages.fooX*
/>
Is it possible? if yes, how to do this?
In the aspx page you may try:
In your code behind on page load call
DataBind();:I am not sure about concatenating the aspx part of the page, you can set the ErrorMessage property of your RegularExpressionValidator in the code behind. Something like:
or