Good day! I can not figure out how to set the default value for the field in the asp.net mvc 4 project. I tried to assign it via:

@Html.EditorFor(model => model.Category, new { @Value = "5" } 

But nothing happened, tried to add through

 int _propertyValue = 5; public int id_Category{ get { return _propertyValue; } set { _propertyValue = value; } } 

It seems like you can predetermine it through the controller, in the GET block, but it also does not work out. Tell me, please, how can this be realized?

    1 answer 1

    So I figured out if someone comes across, here’s the solution:

    Processing must be added to the controller before calling View:

     public int value = 10; public ActionResult Create() { Category_table category_table = new Category_table(); category_table.id_Category = value; return View(category_table); }