title: access local storge with javascript and C#, asp.net
body: <p>i am hoping someone will help me, i am pulling out my hair for the last few hours...! </p>
  
  <p>I am using asp.net web forms with c#</p>
  
  <p>I have the following button in my menu , this button opens up a page that lists selected properties for  realtor… </p>
  
  <pre><code>    htmlCode.Append("&lt;button type='button' class='btn btn-basic' id='btnEnquire'   onclick='openEnquiryPage()'&gt; &lt;span class='glyphicon glyphicon-th-list'&gt;&lt;/span&gt; View my list &lt;/button&gt;");
  
       function openEnquiryPage() {
       location.href = "EnquiryPage.aspx";
      //get the list from the storage into the hidden field
      //getListOfProperties();//not in use...
      }
  </code></pre>
  
  <p>The list is stored in  localstorage as Json, I can see the correct data in the text box on the page </p>
  
  <pre><code>   var retrievedData = localStorage.getItem("propertyArray");
     proplist2.value = retrievedData;
  </code></pre>
  
  <p>declared as follows in asp.net control</p>
  
  <pre><code>   &lt;asp:TextBox ID="TextBox1" runat="server" Text="initial"&gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>BUT in the hidden field, the data is always = ""</p>
  
  <pre><code>  &lt;asp:HiddenField ID="txtPropList" runat="server"&gt;&lt;/asp:HiddenField&gt;
  </code></pre>
  
  <p>javascript to populate the hidden field...</p>
  
  <pre><code>    function getListOfProperties() {
      document.getElementById("body_content_txtPropList").value =    retrievedData;
     var proplist2 = document.getElementById("body_content_txtPropertyList");
      proplist2.value = retrievedData;
      }
  </code></pre>
  
  <p>when I debug the following lines in the code behind ...</p>
  
  <pre><code>    Page.ClientScript.RegisterStartupScript(this.GetType(),"prop", "getListOfProperties();",true);
  
      _propertyListJson = txtPropList.Value;
  </code></pre>
  
  <p>propertyListJson I always = “”</p>
  
  <p>Thank-you in advance.!</p>