vik*_*iki 28 .net asp.net-mvc razor asp.net-mvc-3 html.textboxfor
我使用Razor创建了一个文本框,并尝试设置value如下.
@Html.TextBoxFor(model => model.Destination, new { id = "txtPlace", value= "3" })
Run Code Online (Sandbox Code Playgroud)
我曾尝试追加value与@
@Html.TextBoxFor(model=> model.Destination, new { id = "txtPlace", @value= "3" })
Run Code Online (Sandbox Code Playgroud)
即使它将html input标记呈现为空value
<input id="txtPlace" name="Destination" type="text" value
class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset ui-mini" >
Run Code Online (Sandbox Code Playgroud)
怎么了?
Gaz*_*ter 68
问题是你使用的是小写v.
您需要将其设置为值,它应该解决您的问题:
@Html.TextBoxFor(model => model.Destination, new { id = "txtPlace", Value= "3" })
Run Code Online (Sandbox Code Playgroud)
vik*_*iki 10
我尝试更换value,Value它解决了.它设置value在input现在的标签.
@Html.TextBoxFor(model => model.Destination, new { id = "txtPlace", Value= "3" })
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
116166 次 |
| 最近记录: |