0

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);
}

1 Answer 1

1

If you want it to be hidden:

@Html.Hidden("PropertyName", item.Id);

For textbox:

@Html.TextBox("PropertyName", item.Id);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.