.net 如何将 css 类属性添加到 razor 中的文本框?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4006229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:50:56 来源:igfitidea点击:
How do I add the css class attribute to a textbox in razor?
提问by Magnus Gladh
I have tried:
我试过了:
@Html.TextBoxFor(m => m.UserName, new {@class='textbox'})
which isn't working.
这是行不通的。
回答by takepara
@Html.TextBoxFor(m => m.UserName, new {@class="textbox"})
A c# string literal does not take single quotes.
c# 字符串文字不带单引号。
'textbox' -> "textbox"
“文本框”->“文本框”

