2013-11-04 58 views
0

我在我的MVC應用4這行代碼,將其從MVC 3轉換,而不是變量名:@ Html.LabelFor爲布爾正顯示出真假

@Html.HiddenFor(model => model.IsInhouse) // IsInhoue is bool 

這工作得很好,當應用程序是MVC 3但現在它出現故障。

我試着使用@ Html.LabelFor(model => model.IsInhouse)顯示值,它顯示爲'IsInhouse',並不是說內容值。

在這個問題上的任何線索appriciated。我是MVC的新手。

編輯:替換@ Html.HiddenFor與<input type="hidden" name="IsInhouse" value="@Html.AttributeEncode(Model.IsInhouse)" id="IsInhouse" />解決了這個問題。

回答

2

LabelFor將顯示其屬性名稱,這是它的目的。要獲得其價值,請使用EditorFor