This is my code in .cshtml
. I want to pass value of css to my custom edit for but not working.
@Html.EditorFor(model => model.xxx, new { size = 20, maxLength = 10 , css = "test" })
my code in custom edit for.
@model string
@{
int size = 50;
int maxLength = 50;
string type = "text";
string css = "";
if (ViewData["size"] != null)
{
size = (int)ViewData["size"];
}
if (ViewData["maxLength"] != null)
{
maxLength = (int)ViewData["maxLength"];
}
if (ViewData["type"] != null)
{
type = (string)ViewData["type"];
}
if (ViewData["css"] != null)
{
css = (string)ViewData["css"];
}
}
@Html.TextBox("", Model, new { Size = size, MaxLength = maxLength, Type = type, @class = css})
Well i reproduce your example on MVC 4 and i suppose you should just escape
css
property name inEditorFor
hepler for then it works. Here you are: