forcing a control to refresh

I am finding that there is a lag between setting a value for a control and the control 's visual update. Point in question; If I set a value for a web label’s text property and then go to read the value it immediately after setting it, the web label.text property is still reading “”. I don’t want to introduce a bunch of doevents in an effort to wait for the control to update. Is there a way to force the control to update?

I am not sure to follow. If I set a textfield.text and read it right way, it has changed correctly. This works perfectly :

Textfield1.Text = "gaga" msgbox Textfield1.text

What you describe is not the fact that a property is not changed, it is that it does not display. In a web application, the display is not updated while an event is not finished. So things you do in Desktop may not work. For instance, updating a textfield in a loop will not work, since the update will happen after the loop is over.

DoEvents will not help.

Here is an example of how to update a label while incrementing a variable using a timer. This goes in a timer dragged onto the page Action event :

[code] static i as integer = 1

if i <=10 then
Label1.text = str(i)
i = i+1
end if[/code]

Since the Action event terminates after each incrementation, the Label will update each time.

The timer must be off when the program starts, and launched this way :

Timer1.mode = Timer.ModeMultiple Timer1.enabled = true

May I note that this is a typical event driven way of doing things, when a for next remains procedural.

Correction : I used a static in the event, but as it stands, the result would be that the method would work only once. It needs to be reset when the cycle is over.

Additionally, the timer needs to be stopped at the end of the process.

static myvar as integer = 1 if myvar <=10 then Label1.text = str(i) myvar = myvar+1 else me.enabled = False myvar = 1 end if

Static variables act more like global variables, therefor if you use them in a sub/function or method/event they are not session dependent. Once set they keep their value for all sessions.

Oh. Thank you. That can be an issue. Then it is preferable to use a WebPage or WebContainer property.

Yes, but personally i prefer session.properties, just to keep in mind that they logicaly belong to each other.

But that’s of course depending on the kind of the property.

I should think for a variable destined to be used only in a timer, the ideal way is to subclass the timer and use a class property. So the scope is kept as close to where the property is used as possible.