我怎样才能将样式应用到ASP.NET MVC @ Html.TextboxFor? [英] How can I apply styling to asp.net mvc @Html.TextboxFor?
本文介绍了我怎样才能将样式应用到ASP.NET MVC @ Html.TextboxFor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想改变文本框的背景。这是我的code:
I want to change the background of the textbox. This is my code:
@Html.TextBoxFor(p => p.Publishers[0].pub_name)
更重要的是,我需要在TextBoxFor写改变背景?
What more do I need to write in TextBoxFor to change the background?
在此先感谢:)
推荐答案
在TextBoxFor方法的重载允许你传递一个对象的HTML属性。
An overload of the TextBoxFor method allows you to pass an object for the HTML attributes.
@Html.TextBoxFor(p => p.Publishers[0].pub_name, new { Class="YourBackgroundClass" })
然后你就可以有一个CSS规则,如:
Then you can have a CSS rule such as:
.YourBackgroundClass { background:#cccccc; }
如果你想申请一个直接的风格,你可以做:
If you want to apply a style directly you can do:
@Html.TextBoxFor(p => p.Publishers[0].pub_name, new { Style="background:#cccccc;" })
这篇关于我怎样才能将样式应用到ASP.NET MVC @ Html.TextboxFor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文