[英]How do you pass a model from Editor for model into a controller? (using asp.net)
@model mymodelsnamespace
@using (Html.BeginForm("MyMethodName", "MyContollerName", FormMethod.Post))
{
@Html.EditorFor(m => Model, "Submit", new { multiple = true })
<input type="submit" value="Submit" />
}
I know the code I am going write will be close to whats above 我知道我要编写的代码将接近上面的代码
How do I passed the updated model into MyMethodName is i can continue to manipulate it in my controller? 我如何将更新的模型传递给MyMethodName,这样我才能继续在控制器中对其进行操作?
Please provide the signature for MyMethodName and the cshtml to give the model to the method in the controller. 请提供MyMethodName和cshtml的签名,以将模型提供给控制器中的方法。
If you add this code to your controller, it should work. 如果将此代码添加到控制器中,它将正常工作。
[HttpPost]
public ActionResult MyMethodName (YourModel model)
{
... some code here.
}
You may find the Model-View-ViewModel pattern interesting. 您可能会发现Model-View-ViewModel模式很有趣。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.