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

How to set default value for @HTML.EditorFor in ASP.NET MVC ?

| | ASP-NET

I am going to Explain How we create Default values for model Entities. So Let’s start this via taking a simple example Model class called Post. In Post Model class I have created property PostedOn. Following is a code for that.

private DateTime mPostedOn = DateTime.Now;

    public DateTime PostedOn

    {

        get

        {

            return mPostedOn;

        }

        set

        {

            mPostedOn = value;

        }

 

   }
  @Html.EditorFor(model=> model. mPostedOn)