473,804 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 "CopyDirect ory" 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
Nov 17 '05 #1
4 1705
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/...tures/chester/
http://www.dotnetjunkies.com/tutoria...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/de...s/overview.asp

http://msdn.microsoft.com/downloads/...ce/default.asp

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Roberto López" <ro****@telecab le.es> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
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 "CopyDirect ory" 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

Nov 17 '05 #2
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...

"Roberto López" <ro****@telecab le.es> wrote in message
news:#t******** ******@tk2msftn gp13.phx.gbl...
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 "CopyDirect ory" 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

Nov 17 '05 #3
Hi,
And it´s possible to implement something function like AutoPostBack. Eg. the
option button control like the dropdownlist control has a property
"AutoPostBa ck" 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.

"Roberto López" <ro****@telecab le.es> escribió en el mensaje
news:#t******** ******@tk2msftn gp13.phx.gbl...
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 "CopyDirect ory" 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

Nov 17 '05 #4
It´s really good explained,

Thanks a lot.
"alien2_51" <da********@n.o .s.p.a.m.monaco coach.com> escribió en el mensaje
news:OX******** ******@TK2MSFTN GP09.phx.gbl...
The client has to generate the postback, the client has no knowledge of
anything your doing on the server... It has no knowledge of your class that is responding to events.. In fact, while your page class is bieng processed and is responding to events that are bieng raised the client hasn't even
been issued a response yet.. So your still at the server you don't have a
page or any controls to autopostback from... If you want to use a progress
bar build a windows application... or embed a rich control on your page that can run its process on the client.. The type of syncronization required for a progress bar is not available in a traditional web application that uses
ASP.NET controls...

HTH
"Roberto López" <rl****@eurosis temas.net> wrote in message
news:uc******** ******@tk2msftn gp13.phx.gbl...
Hi,
And it´s possible to implement something function like AutoPostBack. Eg. the
option button control like the dropdownlist control has a property
"AutoPostBa ck" 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.

"Roberto López" <ro****@telecab le.es> escribió en el mensaje
news:#t******** ******@tk2msftn gp13.phx.gbl...
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 "CopyDirect ory"
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



Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
1767
by: DraguVaso | last post by:
Hi, I have a Generic List, for instance: Public MyPersonnesDeContact As New System.Collections.Generic.List(Of clsPersonne) My clsPersonne raises some events, and I want to be able to handle these events. The problem is: when using the WithEvents (Public WithEvents MyPersonnesDeContact As New System.Collections.Generic.List(Of clsPersonne)) I get an error, saying "'WithEvents' variable does not raise any events.".
4
2053
by: Rajiv Das | last post by:
Environment: Visual Studio 2005, Beta 2 ..Net 2.0 Windows XP, SP2 C# Generics ------------------------------- Hi, I have a Windows Form whose contents I would like to dynamically change. I
0
1221
by: Rajiv Das | last post by:
Environment: Visual Studio 2005, Beta 2 ..Net 2.0 Windows XP, SP2 C# Generics ------------------------------- Hi, I have a Windows Form whose contents I would like to dynamically change. I
15
4058
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
3
1849
by: elziko | last post by:
I have a procedure that creates a bitmap of a certain size and then displays it in a 3rd party component. However, if the bitmap is very large then a System.OutOfMemoryException is thrown my something but my codes breaks at the difition of my class: "Public Class MainForm" ....so I'm assuming that the OutOfMemoryException occurs in the 3rd party since I have put a Try-Catch block around my bitmap creation code and I am
10
1575
by: Miro | last post by:
I wanted certain text boxes ( only certain ones ) to always be Trim'd so that spaces are not in the begining, nor the end of the text entered. I created my own "Handle ?" - i hope thats the right terminology, and it works. Is this the right way to do this? I had to use DirectCast to get the textbox name. Private Sub TrimValues(ByVal sender As System.Object, ByVal e As EventArgs) _
2
2847
by: Boki | last post by:
Hi All, We can process the mouse/keyboard events by handling, however, how to create a event on a target form ( ex: webbrowser ) ? Thanks! Best regards, Boki.
0
1440
by: Marc Bartsch | last post by:
Hi, I have a WinForms application (C#, VS 2005) that consists of a treeview control and a notify icon. Below is a complete example of this application. The treeview has one root node and one child node. When I close the form, it will not be closed but minimised to the system tray. A double-click on the notify icon wakes it up and displays it again. My expection was that the treeview handle would be destroyed when the form is sent to the...
10
7072
by: menashay | last post by:
Hello, I am absolute beginner in C# so pardon me if the following question is too easy. I have a form with a one button. When I click the button I want to display a message that reads "Button was clicked" However, I do not want to handle the click event from that form, instead I want to "transfer" that event to a "controller" class that shows that message.
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10359
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.