I have a partial page it is using two View page different controller but there have same Edit
Action method. i need to set controller name dynamically for particular page in the run time . how can i do it ?
My partial page _SearchProduct
in the shared folder it is working only for WomanController
action method Edit
:
<div class="row">
<div class="col-md-6">
@using (Html.BeginForm("Edit", "Woman", FormMethod.Get))
{
<p>
Find by Product Id : @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
<input type="submit" value="Search" />
</p>
}
</div>
<div class="col-md-6">
<span style="color:green">@ViewBag.ProductName </span>
</div>
<span style="color:red"> @ViewBag.FindResult </span>
</div>
My WomanController
EDIT page :
@model MKL.Models.WomanProduct
<hr />
@Html.Partial("~/Views/Shared/_SearchProduct.cshtml")
<hr />
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.WomanProductId)
@if (ViewBag.ProductId != null)
{
@Html.Hidden("ProductId", (int)ViewBag.ProductId)
}
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
My ManController
EDIT page :
@model MKL.Models.ManProduct
<hr />
@Html.Partial("~/Views/Shared/_SearchProduct.cshtml")
<hr />
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.ManProductProductId)
@if (ViewBag.ProductId != null)
{
@Html.Hidden("ProductId", (int)ViewBag.ProductId)
}
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
SO need to dynamically set Partial view Controller name Man
and Woman
@using (Html.BeginForm("Edit", "", FormMethod.Get)){}