發現了一個新問題,這就是爲什麼我要創建一個新帖子。 剃刀發動機不幫助我今天完成工作..剃刀不理解Html.TextBoxFor中帶有或不帶@前綴的ViewBag
使用此代碼我不得到ViewBag.user.UserName印在我的屏幕現在
<td>@Html.TextBoxFor(m => m.UserName, new { @class = "validate[required]", disabled = "disabled", value = @ViewBag.user.UserName }) @Html.ValidationMessage("usernameVal", "*")</td>
,如果我把TextBoxFor像外即:
@ViewBag.user.UserName
我得到了用戶名。
剃刀是否應該足夠聰明以檢測這種情況?
您可以添加您收到的錯誤消息嗎?這將有助於我們縮小問題範圍。 – tristankoffee
爲什麼不簡單地在'ViewBag'前面省略@因爲它已經是服務器端代碼的一部分?如果'@ class'出現問題,請將'ViewBag'放在它的前面... –
@ Html.TextBoxFor(m => m.UserName,new {disabled =「disabled」,value =(with with withou @)ViewBag .user.UserName}) - 這不起作用!還嘗試過:(字符串)ViewBag.user.UserName –