如何從視圖傳遞(綁定)模型到不是[httppost]的控制器方法?如何將綁定模型從視圖傳遞迴(非-httppost)控制器方法
查看:
@Html.EditorFor(model => model.Name)
@Html.DisplayFor(model => model.Model)
// Table displays more properties of model
<input type="button" title="GetStuff" value="Get Stuff" onclick="location.href='@Url.Action("GetStuff")'" />
控制器的方法:
public ActionResult GetStuff(ViewModel Model /* Realize this is non-httppost but...how can I get the model back with this type of scenario */)
{
// Get the name from per the model of the main view if the user changed it
string theName = Model.Name;
Model2 m2 = new Model2(){name = theName};
return ("someView", Model2);
}
你能告訴我控制器的標誌是什麼樣子嗎? – JaJ 2012-03-30 20:04:07
就像你在你的問題中應該可以正常工作。 – Tommy 2012-03-30 20:55:17