@using (Html.BeginForm())
{
int controlWidth=250;
@Html.TextBoxFor(m => m.studentFirstName, new { style = "width:@(controlWidth)px;" })
此代码呈现为
<input data-val="true" data-val-required="The Student First Name field is required." id="studentFirstName" name="studentFirstName" style="width:@(controlWidth)px;" type="text" value="" />
可以理解,我希望它呈现为
<input data-val="true" data-val-required="The Student First Name field is required." id="studentFirstName" name="studentFirstName" style="width:250px;" type="text" value="" />
我看过像ASP.NET MVC Razor Concatenation这样的帖子表明这种方法是正确的。任何想法我做错了什么?