Let’s say I have the following code:
protected void ReservationForm()
{
double x = 50;
double tva = 1.196;
double totalAmount = 0;
totalAmount = x * tva;
ltrl_showText = "Total Amount is " + totalAmount;
}
protected void btn_submit_Click(object sender, EventArgs e)
{
ltrl_previewText = "You ordered nameProduct at the price of " + totalAmount ;
}
How can I get the variable totalAmount from the function above?
I know that with Java I can do this with super() and I found that the equal property on C# is base but I don’t know how to use it. I tried to change the function to public instead of protected but I always get an error.
Thanks for your time.
EDIT: I use AJAX, that’s why the total Amounts are on both functions. The first one I need it because the total amount changes depending the user selection and then on click he sees the preview page.
Use a private field: