How do I send the current item ID and textbox value to the controller after clicking submit button.
@model propertyMgmt.Models.Property
<div class="container" id="tourpackages-carousel">
<div class="panel panel-default" style="width:inherit">
<div class="panel-heading">
<h4 style="font-family:Tahoma, Geneva, sans-serif;margin-left:-5px;">
<strong>@Model.PropertyDescription</strong></h4>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<div>
<img src="~/Image/@Model.PropertyImage" alt="" style="width:100%;height:300px">
</div>
</div>
<div class="col-md-6" style="margin-left:-8px;margin-top:-20px;">
<div style="background-color:#d9dadd">
<h3 style="margin-left:16px;">
<u>Property Details</u></h3>
<dl class="dl-horizontal">
<dt>Total Investment:</dt>
<dd>@Model.InvestmentAmount</dd>
<dt>Remaining Investment:</dt>
<dd>@Model.RemainingInvestmentAmount</dd>
<dt>Property Discription:</dt>
<dd>@Model.PropertyDescription</dd>
<dt>Property Cost:</dt>
<dd>@Model.PropertyCost</dd>
<dt>Country:</dt>
<dd>@Model.Country</dd>
<dt>City:</dt>
<dd>@Model.City</dd>
</dl>
@using (Html.BeginForm("AddInvestment","Home",FormMethod.Post))
{
<input type="number" id="investmentAmount" name="investmentAmount" /><br />
<input type="submit" value="Submit" />
}
</ div >
</ div >
</ div >
</ div >
</ div >
</ div >
The following is the controller with the parameters needed.
[HttpPost]
[Route("AddInvestment/{id}/{amount}")]
public ActionResult AddInvestment(int propertyId, double investmentAmount)
{
Investment investment = new Investment();
investment.PropertyId = propertyId;
investment.InvestorId = Convert.ToInt32(Session["UserId"]);
investment.InvestmentAmount = investmentAmount;
_investmentQueryProcessor.AddInvestment(investment);
RemainingInvestment(propertyId, investmentAmount);
RemainingInvestorBalance(investment.InvestorId, investmentAmount);
return View();
}
I want to understand how I can pass the item Id and textbox value for above parameters using helper tags. I am also not sure about the @using Html.BeginForm()
in the middle. Any help would be appreciated.