Featured post
asp.net - How do I apply date formatting and add attributes to a textbox in MVC3? -
in application, want dates display in mm/dd/yyyy format , want text box limited 10 characters , have class applied it.
to end, made custom editor template date looks this:
@modeltype system.nullable(of datetime) @html.textboxfor(function(d) d, new {.class="polkdate", .maxlength="10"})
then in view can call @html.editorfor(function(m) m.somedate)
, works pretty well. however, because i'm using textboxfor
, doesn't respect displayformat
attribute that's applied model class (i.e. it's spitting out time instead of formatting date).
i love use editorfor
respect formatting want, can't add attributes class , maxlength. tried using plain old textbox
helper, don't know how make generate correct id model binding still works.
anybody know way make happen? don't feel want here outlandish.
this appears trick:
@modeltype date @if date.minvalue.equals(model) @html.textbox("", nothing, new {.class="polkdate", .maxlength="10"}) else @html.textbox("", model.toshortdatestring(), new {.class="polkdate", .maxlength="10"}) end if
looks framework automatically assigns id , name fields of html input tag works properly.
- Get link
- X
- Other Apps
Comments
Post a Comment