I have a VB.NET MVC application and there I have the next code:
<%=Html.EditorFor(Function(m) m.UserName, New With {.class = "someClassName"})%>
which works fine on my dev machine, but returns this error after publishing the application to a QA server:
Compiler Error Message: BC30311: Value
of type ‘ (line 91)’
cannot be converted to ‘String’.
Also if I remove the second param in EditorFor method, it works, e.g.:
<%=Html.EditorFor(Function(m) m.UserName)%>
The error is same for Editor method.
Any ideas?
This is MVC 2 application on .NET 3.5
Update:
The problem not in name of the ‘class’ attribute in this case, as I checked other attributes as well without success.
The method
EditorFordoesn’t have the overload you are using.The ones that have two arguments are:
EditorFor(Expression<Func<TModel, TValue>>, Object)where the object is additional view data.
EditorFor(Expression<Func<TModel, TValue>>, String)where the string is the template name.
The sad thing is that there isn’t any overload that lets you add html attributes.