@model Nullable @{ IDictionary htmlAttributes; object objAttributes; if (ViewData.TryGetValue("htmlAttributes", out objAttributes)) { htmlAttributes = objAttributes as IDictionary ?? HtmlHelper.AnonymousObjectToHtmlAttributes(objAttributes); } else { htmlAttributes = new RouteValueDictionary(); } htmlAttributes.Add("type", "text"); htmlAttributes["class"] += " datefield"; String format = "{0:d}"; @Html.TextBox("", Model, format, htmlAttributes) }