創建一個只讀的文本框,我使用如何在ASP.NET MVC4剃刀
<td>@Html.TextBoxFor("code",new { @readonly="readonly" })</td>
,但得到一個錯誤。什麼是正確的語法?
錯誤:
Error 1 The type arguments for method 'System.Web.Mvc.Html.InputExtensions.TextBoxFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>, System.Collections.Generic.IDictionary<string,object>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. c:\Users\ATPL\Documents\Visual Studio 2012\Projects\AST_MGMT\AST_MGMT\Views\Department\Add.cshtml 7 18 AST_MGMT
指定類型。 'TextBoxFor'(假設存在) –
Will
我認爲問題出在你的字符串文字「代碼」而不是「只讀」。這需要一個與你的模型相關的lambda。例如,如果您有一個名爲'code'的屬性,那麼執行此類錯誤時出現錯誤消息CS1963:表達式樹可能包含一個名爲'code'的屬性,@ Html.TextBoxFor(m => m.code,new {@ readonly =「readonly」})' – Tom
不包含動態操作 – Nisar