Date only from TextBoxFor()
        Posted  
        
            by thekronos
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by thekronos
        
        
        
        Published on 2009-12-25T12:42:25Z
        Indexed on 
            2010/05/16
            4:30 UTC
        
        
        Read the original article
        Hit count: 509
        
asp.net-mvc
Hello,
I'm having trouble displaying the only date part of a datetime into a textbox using TextBoxFor<,>(expression, htmlAttributes).
The model is based on Linq2SQL, field is a DateTime on SQL and in the Entity model.
Failed :
<%= Html.TextBoxFor(model => model.dtArrivalDate, String.Format("{0:dd/MM/yyyy}", Model.dtArrivalDate))%>
Ps : this trick seems to be depreciated, any string value in the object htmlAttribute is ignored.
Failed :
[DisplayFormat( DataFormatString= "{0:dd/MM/yyyy}" )]
public string dtArrivalDate { get; set; }
I would like to store and display the date part only on the details/edit view without the "00:00:00" part.
Any idea please ?
Merry Chrismas from France to all by the way ;-)
© Stack Overflow or respective owner