2013-03-22 64 views
0

在我看來,當我這樣做的下拉列表中正確顯示 -爲什麼在一種情況下顯示下拉列表而不顯示其他情況?

@Html.DropDownListFor(m => m.SelectedEstimateState, Model.EstimateStateList.ToSelectList(c => c.Value, c => c.Text), new { }); 

而不是當我做到這一點 -

@{ 
    Html.DropDownListFor(m => m.SelectedEstimateState, Model.EstimateStateList.ToSelectList(c => c.Value, c => c.Text), new { }); 
} 

兩者有什麼區別?

+0

代碼塊亙古不變的呈現在您的下拉列表 – 2013-03-22 05:03:20

回答

1

這是code block expression,它用於評估表達式。但它不寫出來。更多信息請檢查剃刀語法Razor syntaxweb-programming-using-the-razor-syntax

@{ 
    Html.DropDownListFor(m => m.SelectedEstimateState, Model.EstimateStateList.ToSelectList(c => c.Value, c => c.Text), new { }); 

} 

下面哪裏會寫出來的內容(基本是相同的Response.Write()的編碼)

@Html.DropDownListFor(m => m.SelectedEstimateState, Model.EstimateStateList.ToSelectList(c => c.Value, c => c.Text), new { }); 
相關問題