Rob*_*her 2 html c# asp.net textbox
我想将数据设置到html文本框中.我试过这段代码:
@Html.TextBox("LastName", @value = @ViewBag.FBUserLastName, new { @style = "width: 300px;", @id = "LastName" })
Run Code Online (Sandbox Code Playgroud)
不幸的是,它显示错误.我已经通过ViewData字典设置了此值的代码
试试这个
@Html.TextBox("LastName",
(string)ViewBag.FBUserLastName,
new { @style = "width: 300px;", @id = "LastName" })
Run Code Online (Sandbox Code Playgroud)
你不需要@value
.
此外,你不需要@
在前面ViewBag
,因为你已经打电话@Html.TextBox
,它已经在寻找代码.
您还显然需要将ViewBag属性转换为字符串.