Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello There:

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 :( :( :(

Thanks.

[Edit] Code from OP, removed from answers.
Thanks all of you for the reply. Here is my code.This is my button click event in this code you can see I am updating the
C#
TxtContent.Text

within a loop the text is being returned by a user defined function called
C#
ReturnBodyText()

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.
C#
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();
}



I Hope the above description will help you guys in understanding my problem

Thanks.Smile | :)
[/Edit]
Posted
Updated 24-Aug-11 19:57pm
v2
Comments
walterhevedeich 25-Aug-11 1:20am    
Can you post your code?
asad167 25-Aug-11 1:51am    
you can see my detailed description below.
walterhevedeich 25-Aug-11 1:58am    
Next time, use the Improve Question if you have updates on your question.
Tejas Vaishnav 25-Aug-11 1:33am    
Hello friend please be specify your code, what you want to do with text property.. atleaset some line of code to understand your problem
asad167 25-Aug-11 1:51am    
you can see my detailed description below.

Try This..
ASP.NET
 <form id="form1"  runat="server">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <contenttemplate>
          <asp:TextBox ID="txtChangeValue" runat="server">
        </contenttemplate>
    
 <asp:Timer ID="Timer1" runat="server" Interval="500" ontick="Timer1_Tick">
 
</form>

In Code
C#
static int count = 0;
   protected void Timer1_Tick(object sender, EventArgs e)
   {
       txtChangeValue.Text = count.ToString();
       count += 1;
   }
 
Share this answer
 
v2
Its same as we display some clock or incrementing counter.
Try to use Ajax control toolkit's control like Always Visible Control Extender.
 
Share this answer
 
Use update panel in ASP.Net design
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900