when i go to cshtml page this error occur:
An exception of type 'System.ArgumentException' occurred in System.Web.Mvc.dll but was not handled in user code
in my cshtml code :
<div class="form-group">
@Html.Label("Model", new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.Editor("Model")
</div>
</div>

but on the other hand if i change my code in @Html.Editor("PropertyModel")
it is working perfectly no error occur .
in my model:
public class PropertyAssign {
public int PropertyAssignId { get; set; }
public string PropertyName { get; set; }
public string Model { get; set; }
public DateTime AssignDate { get; set; }
}
In My Controller:
public ActionResult Create()
{
return View();
}
I've tryed this case and it's very strange, but there is some problem with the identifier of your Model property with usage of @Html.Editor() helper.
@Html.Editor("Model") // throws an exception
@Html.EditorFor(m => m.Model) // works fine
Maybe in this context the meaning of Model is the whole model, which is passed to the view, not the single property. But when I've changed the identifier of the Model property to some other, for example SomeModel, everything is fine.
@Html.Editor("SomeModel") // works fine
@Html.EditorFor(m => m.SomeModel) // works fine
So, the possible solutions are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With