I am converting an ASP.NET MVC application to ASP.NET MVC 2 4.0, and get this error:
Operator ‘+’ cannot be applied to operands of type ‘System.Web.Mvc.MvcHtmlString’ and ‘System.Web.Mvc.MvcHtmlString’
HTML = Html.InputExtensions.TextBox(helper, name, value, htmlAttributes)
+ Html.ValidationExtensions.ValidationMessage(helper, name, "*");
How can this be remedied?
You can’t concatenate instances of
MvcHtmlString. You will either need to convert them to normal strings (via.ToString()) or do it another way.You could write an extension method as well, see this answer for an example: How to concatenate several MvcHtmlString instances