I know they now have this in ASP.NET MVC 2.0 <%: Model.CustomerName %>
So when you make HTML helpers is it better to use this way now (provided that you do not want to do HTML encoding)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you always want to use
<%: Model.CustomerName %>from now on where you can. Only in very specific cases should you use<%= %>but try not to use it at all.If you are creating your own html helpers that you don’t want to be encoded, then just return a
MvcHtmlStringfrom them.E.g. This is a extension method I created to display a tick icon if the passed in value is true.
Note that I
EncodeandAttributeEncodeanything that could be dangerous in my extension method and then return aMvcHtmlString.HTHs,
Chares