i'm using asp.net mvc2 and i what to create my own editor template for example to apply to my DateTyme properties.
in View I call my template by this way:
<%=Html.EditorFor(Function(o) o.DataInicio, New With {.class = "defaultTextBox", .maxlength = "16", .style = "width:120px;"})%>
and it works, because i've created my custom template for this porpose, like this:
<%@ 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") %>" />
But the problem comes when i need to retrieve the "AdicionalViewDataObject", becauseon the action i've added some data to the viewdata and on this context (editorTemplate) i don't know how to distinguish the additionalviewdataobject from the previous added data on view开发者_Go百科data.
on this case is suposed to add the attribures to my final html, that i've passed in html.EditorFor method.
can anyone helpme with that?
You may checkout the following article about using additional html attributes with editor templates.
精彩评论