I'm creating an ASP.NET website which will does some calculations (if it's relevant it uses some formulas to calculate retirement plans) the first page, has a bunch of fields and labels that the user will input the numbers, and on key-down i have the JavaScript code running calculations and updating the labels with the numbers. Then I want to pass these values over to the next page where they will be parsed and put into a bar graph for a summary, However I keep getting the default value of the labels. I know this is related to the postback of the page.
I have tried using hidden fields, to store the values but they also are being reset. A lot of the solutions I've seen that are similar to that here I've also tried to no avail.
The javascript code is as follows:
function RATotal() {
$('#lblRATotal').text("$" + (masterRANQAptERI + masterRAPTQptERI +
masterRARQAptERI + lumpsum).format());
masterRATotal = (masterRANQAptERI + masterRAPTQptERI + masterRARQAptERI + lumpsum);
document.getElementById('<%= hiddenRAtotal.ClientID %>').value = masterRATotal;
document.getElementById('hideRAtotal').value = masterRATotal;
}
the ASP/HTML:
<tr>
<td>
<span>Total After-Tax Equivalent Contribution: </span>
<asp:Label runat="server" ID="lblRAATTotal" Text="$X.XX" Font-Bold="true" />
</td>
<td>
<span>Total Pre-Tax Equivalent Contribution:
<asp:Label runat="server" ID="lblRAPTTotal" Text="$X.XX" Font-Bold="true" />
</span>
</td>
<td>
<span>Total Retirement Retirement Income:</span>
<br />
<asp:Label runat="server" ID="lblRATotal" Text="0.00" Font-Bold="true" />
<asp:HiddenField runat="server" ID="hiddenRAtotal" EnableViewState="True" />
<input id='hideRAtotal' name='hideRAtotal' type='hidden' />
</td>
</tr>
The C# code is as follows
protected void btnSummary_Click(object sender, EventArgs e)
{
string RAOtotal2 = hiddenRAtotal.Value.ToString();
Session["RAOtotal"] = RAOtotal2
Response.Redirect("ChartDataQuery.cshtml");
}
Based on everything I've read, this should do the trick... but I am actually just getting a "," or null when I try to play around with it. I've deducted the "," isn't a miscalc because when I set the value to a manually defined string i would also just get a ",". I am still learning these kinds of things, and I would appreciate any help! Thanks!