如何设置html.textboxfor的宽度?

时间:2010-08-26 12:35:05

标签: html asp.net-mvc html-helper

我有一个<%= Html.TextBoxFor(user => user.Name) %>,它有标准宽度。

如何让文本框更广泛?

2 个答案:

答案 0 :(得分:10)

您可以这样做来添加名为singleTextBox的CSS类,然后您可以在样式表中指定宽度:

<%= Html.TextBoxFor(model => model.UserName, new { @class = "singleTextBox" }) %>

在你的样式表中:

.singleTextBox {
    width: 12em;
}

答案 1 :(得分:4)

你也可以使用css风格,它很简单,对我来说很棒

@Html.TextBoxFor(model => model.UserName, new { style = "width: 250px;" })

从Darin的answer获得DropdownList宽度的想法。

希望帮助某人。

相关问题