Reputation: 3
How can i set model properties in view and then send it to controller
@using (Html.BeginForm("Reject", "Maker", FormMethod.Get))
{
<input type="submit" value="Reject" />
@Html.TextBoxFor(model => model._strRejectReason)
}
my model have 2 propeties first one is a string i sent it to controller successfully using the textbox the second one is int id which i want to set it in the view just like Model.id = item.Id; which item is a variable of the loop in each row how can i set the id without using the textbox to send the whole model object to controller
my controller :
public ActionResult Reject(MakerTransactions MakerTransactions)
{
MakerCheckerUnitOfWorkBase _MakerCheckerUnitOfWorkBase = new MakerCheckerUnitOfWorkBase();
MakerTransactions.RouteAgentsConfigsMaker = _MakerCheckerUnitOfWorkBase.RouteAgentsConfigsChecker.RejectMaker(MakerTransactions.id,MakerTransactions._strRejectReason);
return View(MakerTransactions);
}
Upvotes: 0
Views: 1554
Reputation: 1898
If you want it to be hidden:
@Html.Hidden("PropertyName", item.Id);
For textbox:
@Html.TextBox("PropertyName", item.Id);
Upvotes: 1