Hello,
I'm new to the newsgroups so sorry if this is a known issue :)
I am trying to use a TextBox like a Statusbar in a Web Application.
In other words, I want the TextBox to immediately update (refresh) its
contexts when the application runs.
In my test case I have a TextBox and a button. When I click the button,
(MyButtonClick shown below) I update the text. When I run the code,
I only see the last string ("Step 10" ) in the browser window.
I would like to see all the intermediate updates (Step 1, Step 2, ... etc.).
As you can see by my code below, I have tried various statements to force
the page to update each time the TextBox text has changed, but nothing
works, all I see is the last text: "Step 10".
Any suggestions would be greatly appreciated.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;
namespace Test {
public class WebForm : System.Web.UI.Page {
protected System.Web.UI.WebControls.TextBox MyTextBox;
protected System.Web.UI.WebControls.Button MyButton;
private void Page_Load(object sender, System.EventArgs e) {
Response.Expires = -1000;
Response.Cache.SetExpires(DateTime.Now);
Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e) {
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent() {
this.MyButton.Click += new System.EventHandler(this.MyButton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void MyButton_Click(object sender, System.EventArgs e) {
for (int k=0; k<=10; k++) {
MyTextBox.Text = "Step " + k;
Response.Flush();
Response.Cache.SetExpires(DateTime.Now);
Thread.Sleep(500);
}
}
}