c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
asp.net MVC

DisplayFor date format mvc 5

| | ASP-NET , Html , MVC

I want to display the date in the view, but the resulted Date Format is 05/10/2017 12:00:00AM. But I wanted to display like 05-Oct-2017. Before I tried to display using DisplayFor, but it was not suited to display the date format. Finally I found the way to display Date Format.

Instead of using @Html.DisplayFor, I used,

@Convert.ToString(string.Format("{0:dd/MMM/yyyy}", item.DOF))    


Result:

05-Oct-2017

It works perfectly.