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 { });
}

两者有什么区别?

4

1 回答 1

1

这是code block expression,用于评估表达式。但它没有写出来。有关更多信息,请检查剃刀语法Razor 语法web-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 { });
于 2013-03-22T05:01:19.897 回答