0

我正在使用asp.net mvc2和我什麼創建我自己的編輯器模板,例如適用於我的DateTyme屬性。ASP.MVC2編輯器模板缺少額外的HTML屬性

在查看

我把這個方式我的模板:

<%=Html.EditorFor(Function(o) o.DataInicio, New With {.class = "defaultTextBox", .maxlength = "16", .style = "width:120px;"})%> 

和它的作品,因爲我已經創建了我的自定義模板此porpose,像這樣:

<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl" %> 
<input type="text" id="<%=viewdata.ModelMetadata.PropertyName %>" name="<%=viewdata.ModelMetadata.PropertyName %>" value="<%=CDate(model).ToString("yyyy-MM-dd") %>" /> 

但問題當我需要檢索「AdicionalViewDataObject」,因爲我已經添加了一些數據到viewdata和這個上下文(editorTemplate)我不知道如何區分additionalviewdataobject和以前在viewdata上添加的數據。

在這種情況下,suposed將attribures添加到我的最終html,即我通過html.EditorFor方法。

任何人都可以幫助嗎?

回答

0

您可以檢出following article關於在編輯器模板中使用其他html屬性。

+0

感謝但之前提出的問題,我已經發現這篇文章在長時間使用谷歌搜索的嘗試,但我沒有什麼裝飾我的模型與屬性,我假裝是做一些像你做「textboxfor」,你可以聲明內聯htmlattributes呈現,但謝謝 – 2011-04-21 09:10:04