Krokonoster
May 21st, 2010, 03:55 AM
I created a strongly typed partial view for listing a list of products.
Next to each product I have a checkbox.
Also I have two dropdown lists (Actions such as deleting all checked items, and filters like showing all products drafts, etc).
When the dropdown change, I have a jquery that post the form, and my controller action's post method do the rest.
All of this works fine.
I implement the above with RenderAction.
<% Html.RenderAction("ProductList", "Product", new { area = "Product", model = Model.ProductsAvailable }); %>
However, I want to render several of these partials on a single view.
This means I have several forms on that view, which poses several problems.
Anyone ever did something like this? Maybe I'm just over tired but cannot think of a smooth solution right now. Seems I shot myself in the foot going this direction.
For what it matter, my current action methods look as follows (the response.write stuff is just while I'm figuring things out):
[ChildActionOnly]
public ActionResult ProductList(ProductListViewModel model)
{
return PartialView(model);
}
[HttpPost]
public ActionResult ProductList(ProductListViewModel model, List<int> ids)
{
if (!string.IsNullOrEmpty(model.Action) && ids.Count > 0)
Response.Write("Action: " + model.Action);
if (!string.IsNullOrEmpty(model.Filter) && ids.Count > 0)
Response.Write("Filter: " + model.Filter);
return PartialView(model);
}
Next to each product I have a checkbox.
Also I have two dropdown lists (Actions such as deleting all checked items, and filters like showing all products drafts, etc).
When the dropdown change, I have a jquery that post the form, and my controller action's post method do the rest.
All of this works fine.
I implement the above with RenderAction.
<% Html.RenderAction("ProductList", "Product", new { area = "Product", model = Model.ProductsAvailable }); %>
However, I want to render several of these partials on a single view.
This means I have several forms on that view, which poses several problems.
Anyone ever did something like this? Maybe I'm just over tired but cannot think of a smooth solution right now. Seems I shot myself in the foot going this direction.
For what it matter, my current action methods look as follows (the response.write stuff is just while I'm figuring things out):
[ChildActionOnly]
public ActionResult ProductList(ProductListViewModel model)
{
return PartialView(model);
}
[HttpPost]
public ActionResult ProductList(ProductListViewModel model, List<int> ids)
{
if (!string.IsNullOrEmpty(model.Action) && ids.Count > 0)
Response.Write("Action: " + model.Action);
if (!string.IsNullOrEmpty(model.Filter) && ids.Count > 0)
Response.Write("Filter: " + model.Filter);
return PartialView(model);
}