2014-02-27 34 views
2

當剃刀編寫HTML輔助元素,如:Visual Studio中的自動完成HTML輔助

@Html.LabelFor(m => m.MyProperty, new { @class="col-sm-2 control-label" }) 

或者

@Html.TextBoxFor(m => m.MyProperty, new { @class="form-control", placeholder="Property" }) 

Visual Studio是將 「新{」 到 「新的對象{」,然而這是無效的。爲什麼intellisense會這樣做?我錯過了什麼嗎?

+3

它確實給我了。我只是刪除了「對象」部分,並繼續我的一天。 –

回答

1

我想這是因爲this具體超載簽名:

public static MvcHtmlString TextBoxFor<TModel, TProperty>(
    this HtmlHelper<TModel> htmlHelper, 
    Expression<Func<TModel, TProperty>> expression, 
    Object htmlAttributes 
) 

畢竟,htmlAttributes必須有一些那種類型聲明,並Object是他們選擇了最小公分母,因爲dynamic WASN」當這些方法最初被編寫時可用。

這是一種惱人的,對於sure-但智能感知只是在做自己的工作:)

相關問題