Web request from Windows Forms user control
-
I have written a user control, and displayed it on a web page. There is a server side application that is supposed to provide the user control the data. I can do this through setting a property of the user control. What I am stuck at is how to make the user control request data to the server side application. A simple example. I have a user control with a label and a timer on it. On each timer tick, I want the user control to request the server side application to populate the label with the current time at the server.
-
I have written a user control, and displayed it on a web page. There is a server side application that is supposed to provide the user control the data. I can do this through setting a property of the user control. What I am stuck at is how to make the user control request data to the server side application. A simple example. I have a user control with a label and a timer on it. On each timer tick, I want the user control to request the server side application to populate the label with the current time at the server.
The user control is not confined to the typical request/response mechanism of the web page in which it's embedded, so you can communicate with the server using Web Services or .NET Remoting (or some proprietary socket communication, which I wouldn't recommend). So while the page the user is viewing may be static (i.e., they haven't refreshed it) the user control is happilly communicating with the server. Also, you could have the page using XMLHTTP (a scripting component, or automation server) and set properties/call methods on the user control so long as it exposes automation information through dispatch interfaces. See my old article on DevHood about this: User Controls for Windows and the Web[^].
Microsoft MVP, Visual C# My Articles