c# ,webforms,vs2003, frames
i have a web form that have two frames top frame and main frame and the top frame contains all the links to the pages wich is loaded in the main frame and lets say i have 2 web forms (webform1 & webform 2.
my problem is every time i change web form using the links at run time what ever the veriable values that was left on the other page nerver changes to thair original state like when the page is loaded at the fist time
lets say i have a cal culculation in the fist webform1 which is dis played on the page load and the second one the same way as the first when the fist page loads it gives me the answer =3
and when i go to the second page and it gives me the answer =3 again when i come back to the first one it gives me the answer =6 and go to the second it gives me the answer =6
whey is this happening why arn't the variables getting re-initialized
please help me
************************************************************ webform1 (statrting form)
namespace sen { public class Products : System.Web.UI.Page { int total=0; int var1=1; int var2=2; private void Page_Load(object sender, System.EventArgs e) { int total=var1+var2; lblno.Text=total.ToString(); } } }
********************************************************************
webform2
namespace sen { public class Products : System.Web.UI.Page { int total=0; int var1=1; int var2=2; private void Page_Load(object sender, System.EventArgs e) { int total=var1+var2; lblno.Text=total.ToString(); } } }
Ok, dude i dont quite get your question, and i'm not much of an ASP person, but from what i can tell. there is a bug in your code since your field total decleared as ant int is not updated by any code thus will remain the same. try not re-declaring it again in the page_load method.
ex.
class calc
{
int total = 0;
static void Page_Load(params..)
{
int lval1 = 2;
int rval2 = 5;
total = lval1 + rval2;//you dont have to re-declare it in this method since its globally accessible
}
}