title: Saving a value to and reading from the viewstate
body: <p>I'm not too familiar with .NET, but I want to save a simple value (a number between 1 and 1000, which is the height of a particular <code>div</code>) to the viewstate and retrieve it when the update panel reloads (either in the markup somewhere or with javascript). What is the simplest way to do this?</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/aa287536%28v=vs.71%29.aspx" rel="noreferrer">This page</a> gives me the following code:</p>
  
  <pre><code>string strColor;
  if (Page.IsPostBack)
  {
     // Retrieve and display the property value.
     strColor = (string)ViewState["color"];
     Response.Write(strColor);
  }
  else
     // Save the property value.
     ViewState["color"] = "yellow";
  </code></pre>
  
  <p>However, I'm not totally clear on where or how to access the example strColor. </p>
  
  <p>Since this is in the code behind, where will <code>Response.Write</code> even spit that code out? I couldn't find it when I tried this code. And how do I use javascript to set that value, instead of setting it in the code behind? </p>