title: Asp.net "Global" variables
body: <p>I'm writing a page in ASP.NET and am having problems following the cycle of initialization on postbacks:</p>
  
  <p>I have (something akin to) the following:</p>
  
  <pre><code>public partial class MyClass : System.Web.UI.Page
  {
      String myString = "default";
  
      protected void Page_Init(object o, EventArgs e)
      {
          myString = Request["passedString"];
          //note that I've tried to set the default here in Init on NULL...
      }
  
      protected void Page_Load(object o, EventArgs e)
      {
           if(!Postback)
           {
               //code that uses myString....
           }
           else
           {
              //more code that uses myString....
           }
      }
  }
  </code></pre>
  
  <p>And what's happening is that my code picks up the "passedString" just fine, but for some reason, on postback, it resets to the default value - even if I put the assignment of the default in the Page_Init code... which makes me wonder what's going on..</p>
  
  <p>Any help?</p>