title: Losing TextBox value when using UpdatePanel in ascx?
body: <p>I have 2 update panel in one update panel i have a datalist and in other update panel I have a textbox with tinymce editor.</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
  &lt;ContentTemplate&gt;
   &lt;asp:DataList ID="dlst1" runat="server" RepeatDirection="Horizontal" CellSpacing="5" CellPadding="7" 
       DataKeyField="Id" CaptionAlign="Left" OnItemCommand="dls1_ItemCommand"                        
       OnItemDataBound="dlst1_ItemDataBound"&gt;
     &lt;ItemTemplate&gt;
       &lt;asp:ImageButton ID="btnImg" OnClientClick="javascript:void(0);" 
         runat="server" ImageUrl='&lt;%#"~/Controls/Images.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %&gt;' 
         CommandName="Select" OnCommand="Select_Command" 
          CommandArgument='&lt;%# Eval("Id").ToString() ' /&gt;   
     &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  &lt;/ContentTemplate&gt;
  
  &lt;asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always"&gt;
  &lt;ContentTemplate&gt;
     &lt;asp:TextBox ID="TextBox1" CssClass="tinyEditor" ClientIDMode="Static" runat="server" TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;
  &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>for making tinymce worked I am using</p>
  
  <pre><code>ScriptManager.RegisterClientScriptBlock(UpdatePanel2, this.GetType(), "init", "tinyMCE.execCommand('mceAddControl', false, '" + TextBox1.ClientID + "');", true);
  
  var prm = Sys.WebForms.PageRequestManager.getInstance();
  prm.add_endRequest(function () {
  TinyMCEEditor();
  });
  
  $(function () {
  TinyMCEEditor();
  });
  </code></pre>
  
  <p>my TinyMCE Editor</p>
  
  <pre><code> function TinyMCEEditor() {
  tinyMCE.init({
      mode: "textareas",
      theme: "advanced"
  });
  }
  </code></pre>
  
  <p>on page load.</p>
  
  <p>I am giving the text for every image, for the previous image I am storing the textbox value in a view state, suppose I have 3 images for image 1 i have given the text abcd and selected image2, so image 1 text will store in the viewstate.</p>
  
  <p>on Select_Command:</p>
  
  <pre><code> if (ViewState["txbtext"] != null)
              txbtext= (Hashtable)ViewState["txbtext"];
          int index1 = previouslySelectedIndex;
          if (index1 != -1)
          {
              ImageButton imgbtn= (dlst1.Items[index1].FindControl("btnImg") as ImageButton);
              if (imgbtn!= null)
              {
                  string[] ImgStr = imgbtn.CommandArgument.ToString().Split(';');
                  Int32 selectedId = Convert.ToInt32(Str[0]);
                  if (txbtext!= null &amp;&amp; txbtext.ContainsKey(selectedId))
                      txbtext[selectedId] = textbox.Text;
                  else
                      txbtext.Add(selectedId, textbox.Text);
              }
          }
          ViewState["txbtext"] = txbtext (//this is the hashtable);
        }
  </code></pre>
  
  <p>when I was not using update panel it was working fine, but as I am using update panel I am not able to store the textbox value in viewstate,</p>
  
  <p>Please someone tell me how can I fix this issue, if possible give some exp. code.</p>
  
  <p>Some one plz help me</p>