我已经使用下面的代码来添加css类@Html.TextBox
但这只适用于@Html.TextBoxFor
而不适用于@Html.TextBox
。如何在@ Html.TextBox中添加新的CSS类mvc4
@Html.TextBox("ticket_new_attachment_attributes_0_description", new { @class= "bigfield"})
我缺少什么?
我已经使用下面的代码来添加css类@Html.TextBox
但这只适用于@Html.TextBoxFor
而不适用于@Html.TextBox
。如何在@ Html.TextBox中添加新的CSS类mvc4
@Html.TextBox("ticket_new_attachment_attributes_0_description", new { @class= "bigfield"})
我缺少什么?
尝试此
@Html.TextBox("ticket_new_attachment_attributes_0_description", null, new { @class= "bigfield"})
的第二个参数是value。
您需要使用过载与第三参数的HTML属性,像这样:
// Pass null (or the value) as second parameter
@Html.TextBox("ticket_new_attachment_attributes_0_description", null, new { @class = "bigfield"})
对于@ Html.TextBox第二个参数是文本框的值 是这样,你可以通过“”作为文本框的值和第三个参数是HTML属性
尝试下面的html:
@Html.TextBox("ticket_new_attachment_attributes_0_description", "", new { @class= "bigfield"})
3年前提问这个问题...目前有最佳答案。 – rakaz
这是GR8,其工作。谢谢 –
这段代码确实有用,但请注意,马里奥Sannum给出了一个理由,为什么在他的答案下面。第二个参数是值,第三个参数是属性。 –