Link to home
Start Free TrialLog in
Avatar of sean-keys
sean-keys

asked on

String in web form keeps going to null c#

I have this code to make a string called MODE.

          public class customers : System.Web.UI.Page

                         public string MODE="UPDATE";

Then I have a method to change the value of MODE

private void ChangeCustomerMode(string Mode)
      {
            string Change = Mode;
                  if (Change == "ADD")
                        {
                              MODE="NEW";     //I watch it set to "NEW"
                              btn_add_customer.Visible = false;
                              btn_update_customer.Text = "Add New Customer";
                        }
                  if (Change == "UPDATE")
                  {
                        MODE="UPDATE";
                        btn_add_customer.Visible = true;
                        btn_update_customer.Text = "Update Selected Customer";
                  }

}

At this point the debugger says the value is now "NEW"

But then I call this method

private void btn_update_customer_Click(object sender, System.EventArgs e)
            {
                  StoreCustomerInfo();
             }

private void StoreCustomerInfo()
            {                                                      
                        
                  if (MODE == "NEW")                           // right here it reads as "UPDATE"
                  {
                        AddCustomer();
                  }
                  else
                  {
                  }

            }

and the MODE is back to "UPDATE"

What am I doing wrong??????    

Thanks,
Sean
ASKER CERTIFIED SOLUTION
Avatar of BurntSky
BurntSky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial