asp.net MVC

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

How to set default value for @HTML.EditorFor in ASP.NET MVC ?, someone asked me to explain?

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)

 

Post your comments / questions