How to handle personalized events of a class in a web form?

R

Roberto López

Hello,
I´m trying to do a progress page that indicates some visual information to
the user in a long directory copy process. I have a Class that copys
directories from one location to other. The function "CopyDirectory" is
started in a new Thread. This class also contains one Event that is raised
every directory is copied.
On my page I have declared an instance of my class with the "WithEvents"
modifier and i have writed an event handler for the class event into the
page. Every time the event is raised I change the text property of a textbox
in the page but it not shows because the page not refresh the textbox value.
I don´t know if it is possible to do this in a Web page. (I think In windows
forms it may be run).
Any suggestions will be apreciated.

Thanks.

Roberto López
 
S

Steve C. Orr, MCSD

The problem is that only the page can request a refresh of itself. You
can't do it from the server side.
You can have the browser refresh the status by putting an HTML line like
this in your code:
<META HTTP-EQUIV="refresh" CONTENT="3">
That will cause the browser to refresh every 3 seconds (and you can check
the status of the operation each time and redirect to a "done" page when
appropriate.)
Here's more details:
http://www.fawcette.com/vsm/2002_11/magazine/features/chester/
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=547

Another option is that you could call a web service from your client side
JScript. Use the web service behavior for this. (WebService.htc) This
technique works with IE only.
Here's more details:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/overview.asp

http://msdn.microsoft.com/downloads...rnet/behaviors/library/webservice/default.asp
 
A

alien2_51

Because of the disconnected stateless nature of a web application I don't
this approach will work.. Here's what I'm guesing is happening..
Your page is recieving the events as they are raised by your class declared
WithEvents but the page is only rendered once after the last event fired
(synchronous execution, meaning the page is not rendered until all the
processing is done) so your TextBox has the last directory that was copied
written to its text property...To verify this set a breakpoint in your event
handler and see if you are hitting that breakpoint...
 
R

Roberto López

Hi,
And it´s possible to implement something function like AutoPostBack. Eg. the
option button control like the dropdownlist control has a property
"AutoPostBack" that do a page postback when the control changed. How can I
implement something like this to post bak the page when the clas event is
raised.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top