Morning SO,

I've been scratching my head over this for a few days - but had limited trials at getting it to work; I am trying to dynamically assign a value to a TEXTBOXFOR control's Width.

@Html.TextBoxFor(m => m.Items[i].Title, new { @Style = string.Format("width:{0}px;", Model.Items[i].Width), @ReadOnly = "true" })

<label style="width:@Model.Items[i].Width px; padding-top:8px;">@Model.Items[i].Title</label>

@Html.TextBoxFor(m => m.Items[i].Title, new { @Style = "width:" + Model.Items[i].Width + "px;", @ReadOnly = "true" })

I have tried a few other examples - but nothing seems to actually work.

Does anybody have a correct format?

Related posts

Recent Viewed