views:

340

answers:

1

hiya

when using EditorFor(model => model.FieldName)

i want to have a generic say datepicker, rich text editor, upload box etc but with editorFor you cant pass a value, so you have to create a strongley typed element for each model that requires one of the above.

anyone know if you can pass a generic model or a generic value like using <T>() ???

thnaks

+1  A: 

man i am NOT on form today, just realised you can pass over a type rather than a model

for example here is my jquery DatePicker to be used on everyfield i UIHInt with DataPicker

`<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime>" %>

<%=Html.TextBox(ViewData.TemplateInfo.HtmlFieldPrefix,Model.ToShortDateString(),new{Class="DatePicker"})%>`

my JS then looks like:

$(document).ready(function() {
        $(".DatePicker").datepicker({ dateFormat: 'dd/mm/yy' });
    });

and my view simply runs like this:

<div class="editor-field">
            <%= Html.EditorFor(model => model.EventDate) %>
            <%= Html.ValidationMessageFor(model => model.EventDate) %>
        </div>
minus4