Hello,
I am writing a prog with ASP in C#.
I have 2 separate pages.
on the first page there are 2 textboxes and a button.
the first box is a validation check (a code)
the second one is the ammount of money you want to withdraw (max of 1000)
if I test it, it works. when I type the correct code and an ammount thats Lower than 1000. it will print my current credit in the next page. (type 200 in the second textbox and the next page will say: Current Credit: 800).
However when I press the back button on that screen it will reset the value to 1000 instead of keeping it 800
My actual question is. how do I send an Int trough a session instead of a string?
If I know that I can make a new int that has a value of 0 and when it runs trough the next page it will change to 1 and I can create an if-else about the total ammount of money. since strings are static and not able to change I cannot do it that way.
sorry for the long text to explain something simple.
This is my current code, which do not work:
FIRST PAGE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Opdracht5
{
public partial class _Default : System.Web.UI.Page
{
int totaal;
int saldo;
string invoer1;
string invoer2;
int bedrag;
string resultaat;
int hulpint;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Application.Add("hulpint", "" + hulpint);
if (hulpint.Equals("1"))
{
goto spring;
}
else
{
totaal = 1000;
}
spring:
Application.Add("totaal", "" + totaal);
Application.Add("saldo", "" + saldo);
invoer1 = TextBox1.Text;
invoer2 = TextBox2.Text;
bedrag = Int32.Parse(invoer2);
resultaat = Convert.ToString(saldo = totaal - bedrag);
Session.Add("resultaat", "" + resultaat);
if (invoer1.Equals("1234"))
{
if (bedrag < saldo && bedrag > 0)
{
Response.Redirect("WebForm1.aspx");
}
else
{
Response.Redirect("foutiefbedrag.aspx");
}
}
else
{
Response.Redirect("foutepincode.aspx");
}
}
}
}
SECOND PAGE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Opdracht5
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string resultaat = Session["resultaat"].ToString();
Response.Write("NIEUW SALDO: € " + resultaat);
string hulpint = Application["hulpint"].ToString();
hulpint.Equals("1");
}
protected void BackButton3_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
}
}