update the textbox text property through loop
<p>I want to update the text property of my textbox control in Asp.Net from within loop.I have tried using Ajax updatepanel with the timer control but unable to update the text property.I have been searching this since last week but unable to find any answer any help would be higly appreciated</p>

<p>Following is the detail:</p>

<p>This is my button click event in this code you can see I am updating the</p>

<pre><code>TxtContent.Text
</code></pre>

<p>within a loop the text is being returned by a user defined function called</p>

<pre><code>ReturnBodyText()
</code></pre>

<p>afterwards I am assigning the text to the viewstate so that at the timer tick event I can recall the text and update the textbox text property and then at the timer tick event assigning the viewstate values to the textbox.</p>

<pre><code>protected void Button4_Click(object sender, EventArgs e)
{
    ArrayList FilePath = (ArrayList)ViewState["ArrayList"];
    int i = 0;
    int b = 1;
    foreach(string[] sr in FilePath)
    {
        string Month = sr[i];
        string datewithzero;
        datewithzero = String.Format("{0:00}", b);
        string[] FilesArray = (string[])listfiles(Month, datewithzero).ToArray(typeof(string));

        foreach (string FileNameWithExtension in FilesArray)
        {
            ListBox4.Items.Add(FileNameWithExtension);
            TxtContent.Text = ReturnBodyText(Month, datewithzero, FileNameWithExtension);
            ViewState["Content"] = TxtContent.Text;
            Timer1.Enabled = true;
            Timer1_Tick(ViewState["Content"], e);
        }
        i = i + 1;
        b = b + 1;
    }
}

protected void Timer1_Tick(object sender, EventArgs e)
{
    TxtContent.Text =(string) ViewState["Content"];
    TxtContent.DataBind();
}
</code></pre>

<p>I Hope the above description will help you guys in understanding my problem</p>

<p>The complete aspx file and the code behind is as follows:</p>

<ul>
<li><p><strong>Aspx Code:</strong></p>

<p>&lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %></p>

<p>&lt;%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %></p>

<p></p>

<p>

    


    
    </p>

<pre><code>    &lt;asp:ListBox ID="ListBox1" runat="server" Height="509px" Width="59px"&gt;
    &lt;/asp:ListBox&gt;

    &lt;asp:Button ID="Button2" runat="server" Height="26px" onclick="Button2_Click" 
        Text="To be pressed first" Width="130px" /&gt;

    &lt;asp:Button ID="Button3" runat="server" onclick="Button3_Click" 
        Text="To be pressed 2nd" Width="131px" Height="26px" /&gt;

    &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
    &lt;/asp:ScriptManager&gt;

            &lt;asp:Timer ID="Timer1" runat="server" Interval="1000" 
        ontick="Timer1_Tick" Enabled="False"&gt;
            &lt;/asp:Timer&gt;
    &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
        &lt;ContentTemplate&gt;
            &lt;asp:TextBox ID="TxtContent" runat="server" Height="508px" AutoPostBack="True" 
                TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;
            &lt;asp:Button ID="Button5" runat="server" Height="26px" onclick="Button4_Click" 
                Text="To be pressed Third" Width="122px" /&gt;

        &lt;/ContentTemplate&gt;
        &lt;Triggers&gt;
            &lt;asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /&gt;
        &lt;/Triggers&gt;
    &lt;/asp:UpdatePanel&gt;

&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>
</p>

<p><strong>- Codebehind:</strong></p>

<p>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Collections;</p>

<p>public partial class _Default : ftp 
{</p>

<pre><code>protected void Button2_Click(object sender, EventArgs e)
{
    string[] array = (string[])listfiles().ToArray(typeof(string));
    ViewState["FolderName"] = array;
    foreach (string FileName in array)
    {
        ListBox1.Items.Add(FileName);
    }
}
protected void Button3_Click(object sender, EventArgs e)
{
    string[] arraylistbox2 = (string[])ViewState["FolderName"];
    string[] arrays = new string[12];
    ArrayList ListPath = new ArrayList();
    int dateFolder;
    foreach (string  FileName in arraylistbox2)
    {
        dateFolder =  Convert.ToInt16(FileName);
        dateFolder = dateFolder - 1;
        ListPath.Add((string[])(listfiles(FileName).ToArray(typeof(string))));
    }
    ViewState["ArrayList"] = ListPath;
}
protected void Button4_Click(object sender, EventArgs e)
{
    ArrayList FilePath = (ArrayList)ViewState["ArrayList"];
    int i = 0;
    int b = 1;
    foreach(string[] sr in FilePath)
    {
        string Month = sr[i];
        string datewithzero;
        datewithzero = String.Format("{0:00}", b);
        string[] FilesArray = (string[])listfiles(Month, datewithzero).ToArray(typeof(string));

        foreach (string FileNameWithExtension in FilesArray)
        {

            TxtContent.Text = ReturnBodyText(Month, datewithzero, FileNameWithExtension);
            ViewState["Content"] = TxtContent.Text;
            Timer1.Enabled = true;
            Timer1_Tick(ViewState["Content"], e);
        }
        i = i + 1;
        b = b + 1;
    }
}
protected void Timer1_Tick(object sender, EventArgs e)
{

    TxtContent.Text =(string) ViewState["Content"];
    TxtContent.DataBind();


}
</code></pre></li>
</ul>
