Problem
I am trying to implement an HTML5 / jQuery layout in MVC and am facing a problem that I have never encountered; it appears using Html.TextBoxFor, Html.PasswordFor and others that automatically encode passed HTML attributes.
Example
Take the following line, for example:
@Html.TextBoxFor(m => m.Pin, new { data_regexp="<\\d{4}>" })
This code will be used to verify the PIN code on the credit card, and I need to use the regexp data template to pass the corresponding regular expression. I expect the result to be as follows:
<input data-regexp="<\d{4}>" id="Pin" type="text" />
Instead, it apparently calls the HtmlAttributeEncode ( http://msdn.microsoft.com/en-us/library/wdek0zbf.aspx ) from the built-in extension, which results in the following encoded :
<input data-regexp="<\d{4}>" id="Pin" type="text" />
Desired Solution Note
Do I have another option than writing my own extensions? Using other forms of validation is not an option, and this example - just to show the problem - I have a few other examples where I need raw HTML code and not an encoded version.
Edit: Using Html.Raw or HttpUtility.Decode is not affected. Coding occurs after applying any of them.
source share