I defined this DateTime.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime?>" %>
<%: Html.TextBox( string.Empty,
(Model.HasValue ? Model.Value.ToString("dd.MM.yyyy") : string.Empty),
new { @class = "whatever"
}
)%>
and the aspx site looks so:
<%: Html.EditorFor(model => model.Data.birthday) %>
The idea is now that a javascript function "ABC()" is called when ever the textbox loses the focus (means "onBlur" event) (ideally: the value of the trextbox is passed to the called function "ABC(birtday.value)") But I would not like to change the DateTime.ascx to end up that ALL(!) EditorFor (for Datetimes) will have an javascript function call!
My tries: This
<%: Html.EditorFor(model => model.Data.birthday, "onBlur='javascript:ABC();'", "birthday") %>
results in
<input class="whatever" id="birthday" name="birthday" type="text" value="25.08.2010" />
but the onBlur / javascript function call is not set.
And
<%: Html.EditorFor(model => model.Data.birthday, new { onClick="javascript:ShowHideC1();"} ) %>
doesnt work either.
(Next step is then that this textbox is "of course" a jquery datepicker ;-)