2013-06-12 31 views
0

我想喜歡創建這樣一個數據彈出屬性的輸入框:Html5數據彈出與.NET MVC 4 Razor EditorFor擴展?

<input type="text" name="title" data-popup="test">

我試圖用

@Html.EditorFor(model => model.Name , new { data_popup = "Hashtag" })

但數據彈出屬性不會被渲染。 是否可以爲編輯器添加類似data-popup的屬性?

回答

4

我相信如果您使用TextBoxFor而不是以相同的方式,您會得到您想要的結果。

之所以存在是EditorFor不具有htmlAttributes參數,要傳遞的參數是additionalViewData參數,因此,作爲HTML屬性將不會被渲染..