Display only date and no time

Total Post:10

Points:70
 218  View(s)
Ratings:
Rate this:

I want just  date to be displayed not time in partial view

model.ReturnDate = DateTime.Now; 

return PartialView("PartialView", model);  


  1. Post:1

    Points:7
    Re: Display only date and no time

    use this syntax in your partial razor view

    @Html.Label(Model.ReturnDate.ToShortDateString())

  1. Post:140

    Points:984
    Re: Display only date and no time

    Date only not time is display in partial view:

    Please use a templates with field access,property access,single-dimension array index only.

    @Html.EditorFor(model => model.ReturnDate.ToShortDateString()) 

    or 

    @Html.EditorFor(model => model.ReturnDate.ToString("MM/dd/yyyy")) 

    partial view: 

    @Html.EditorFor(model => model.ReturnDateForDisplay) 

    please use this method for partial view in razor as a render action. 

    <div> @Html.Partial("_mindstick") </div>    
    div> @{Html.RenderPartial("_mindstick");} </div>  

    i hope, it will be useful for you.

    Happy Coding :)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!