I have a view where I got my Ajax.BeginForm and it submits as it should. But then I have a "save icon" and when I press that button I need the values from inside the form. The form submits presents a calculation and the save icon is suppose to save it all.
But when I press the save icon (with Url.Action("SaveExcel", "Save") I can't get the values from the textboxes. How do I do that?
My HTML:
<a href="@Url.Action("SaveExcel", "Save")" title="Save"><img src="../../Images/glyphicons_446_floppy_save.png" alt="save" id="saveIcon"></a>
<!-- Contains forms and input for annuity calculation -->
<div class="calcInput" id="calcInput">
@using (Ajax.BeginForm("ShowDetailAnnuity", "Calculation", new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "CalcDetail",
LoadingElementId = "Loader",
}))
{
<div class="calculateBox">
<label for="calcOption">Choose value to calculate:</label>
<select id="calcOption" name="calcOption" title="Choose what value you want to calculate">
<option value="PMT" id="PMT" name="PMT">Payment (PMT)</option>
<option value="I" id="I" name="I">Interest (I)</option>
<option value="FV" id="FV" name="FV">Future value (FV)</option>
<option value="PV" id="PV" name="PV">Present value (PV)</option>
</select>
</div>
<div class="calculateBox" background-color="#777777">
@Html.Label("Present value (PV)", new { @id = "pvLabel" })
@Html.TextBox("PresentValue", null, new { @class = "PresentValue" })
@Html.Label("Future value (FV)", new { @id = "fvLabel" })
@Html.TextBox("FutureValue", null, new { @class = "FutureValue" })
@Html.Label("Interest rate", new { @id = "intRateLabel" })
@Html.TextBox("InterestRate", null, new { @class = "InterestRate" }) <br /> <br />
<input type="radio" name="advanceOrArrears" id="inAdvance" value="inAdvance" /> In advance<br />
<input type="radio" name="advanceOrArrears" id="inArrears" value="inArrears" /> In arrears
</div>
<div class="calculateBox">
<label for="startDate">Start date:</label>
<input type="date" id="StartDate" name="startdate" title="Choose start date for your calculation" /><br />
@Html.Label("Payment frequency")
<select id="PmtFreq" name="PmtFreq" title="Choose the payment frequency, for example: Every month">
<option value="Monthly">Monthly</option>
<option value="Quarterly">Quarterly</option>
</select><br /><br />
@Html.Label("No of payment periods")
@Html.TextBox("PaymentPeriods")
@Html.Label("Date time convention")
<select id="DTC" name="DTC" title="Choose your Date time convention">
<option value="360/360">360/360</option>
<option value="365/365">365/365</option>
</select><br /><br />
<input type="submit" id="CalcBtn" class="calcBtn" name="SubmitBtn" value="Calculate" title="Calculate your calculation" />
</div>
}
</div>
My controller:
public class SaveController : Controller
{
public ActionResult SaveExcel(string PresentValue) //Can't get PresentValue here..
{
return View();
}
}
I have tried using the names of the textboxes as parameter in the controller, and I have also tried Request.Form["PresentValue"] but nothing of that works