By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 2,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

ASP.Net with Asynchronous Web Service calls

P: n/a
Hi
I have asked a similar question on the web services discussion group, but the question is a bit more related to ASP.Net. Basically I have a ASP.Net application that calls a web service asynchronously. This is fine. My problem is that when I make a call to the web service asynchronously when I get the return which is passed into a static method I cannot reference any Web Contorls to paste the return values into from within the static method.

I have been advised to create a static field and add the value retuned to the static methos to the static field which should be referenceable from all methods. Again fine.

However my question is how do I then tell the cntrol that will display my returned value to pick it up?

A typical sequence would b

1. Client makes async call. Passes in static methos name to send the results to on completion
2. browser can do wor
3. static method picks up result,
4. needs to tell asp.net to now pick up the result and show it

point 4 is my problem

Any help appreciated
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
You need to have your static method be part of a class, and create an event
in the class. In your ASP.NET routine, attach a delegate (handler) to the
event, and raise it when you have the results.

"Trotsky" <an*******@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
Hi,
I have asked a similar question on the web services discussion group, but the question is a bit more related to ASP.Net. Basically I have a
ASP.Net application that calls a web service asynchronously. This is fine.
My problem is that when I make a call to the web service asynchronously when
I get the return which is passed into a static method I cannot reference any
Web Contorls to paste the return values into from within the static method.
I have been advised to create a static field and add the value retuned to the static methos to the static field which should be referenceable from all
methods. Again fine.
However my question is how do I then tell the cntrol that will display my returned value to pick it up??
A typical sequence would be

1. Client makes async call. Passes in static methos name to send the results to on completion. 2. browser can do work
3. static method picks up result,
4. needs to tell asp.net to now pick up the result and show it.

point 4 is my problem.

Any help appreciated.

Nov 18 '05 #2

P: n/a
Many thanks Ricky. Are you aware of any useful ( msdn ) references for this
Nov 18 '05 #3

P: n/a
Not for this specific case, but you might want to prowl around for general
information about delegates and events.

"Trotsky" <an*******@discussions.microsoft.com> wrote in message
news:34**********************************@microsof t.com...
Many thanks Ricky. Are you aware of any useful ( msdn ) references for this?

Nov 18 '05 #4

P: n/a
Thanks again. I had a go at this. However I have came across another issue. My app now does the followin

1. Creates a class ( AsynCall.cs ) that takes care of the asynchronous web services call, and raising of events when the result is returned from the web service
2. passes a reference from the .aspx.cs class ( this ) to the AsynCall object. This is because the .aspx.cs class will be listening for the reslt when it is available from the Asyn web services call
3. The AsynCall class defines an event that is raised when the asynchronous call returns. The .aspx.cs class has a method that matches the method definition defined by a delegate in AsyncCall.cs, and has registered its method with the handler
4. The aync result is returned and the appropriate event is raised, I can write to debug to check I am in the correct aspx.cs class and the correct result has been returned from the web service call
5. When I try to then write the result to a label on the form nothing appears.

point 5 is my problem

again any help greatly appreciated
Nov 18 '05 #5

P: n/a
The page isn't being reloaded just because the event occurs. You might have
to force this - try saving the result from the web service in session state,
(or adding it to your page's URL as a query string) and then do a
server.transfer back to the same page, pick up the value and put it into
your control. (I haven't tried this <g>)

"Trotsky" <an*******@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
Thanks again. I had a go at this. However I have came across another issue. My app now does the following
1. Creates a class ( AsynCall.cs ) that takes care of the asynchronous web services call, and raising of events when the result is returned from the
web service. 2. passes a reference from the .aspx.cs class ( this ) to the AsynCall object. This is because the .aspx.cs class will be listening for the reslt
when it is available from the Asyn web services call. 3. The AsynCall class defines an event that is raised when the asynchronous call returns. The .aspx.cs class has a method that matches the
method definition defined by a delegate in AsyncCall.cs, and has registered
its method with the handler. 4. The aync result is returned and the appropriate event is raised, I can write to debug to check I am in the correct aspx.cs class and the correct
result has been returned from the web service call. 5. When I try to then write the result to a label on the form nothing appears.
point 5 is my problem.

again any help greatly appreciated.

Nov 18 '05 #6

P: n/a
I tried your suggestion ( and also a simple redirect to a new page ) from my method in the original aspx.cs class that matches the delegates required signature, but nothing happened ( on the Page, it still logs to the debug window that it is in the correct method )
Nov 18 '05 #7

P: n/a
I went through the stack trace and for a redirect it ( the aspx page ) throws an exception stating

"Response is not available in this context

For the Server.Transfer I get "Error executing child request for". MSDN recommends redirect.

http://support.microsoft.com/default...kb;en-us;32043

Regardless both fail
The annoying this is when I look in the locals window I can see the result returned from the web service is assigned to the label control on the form. It just isn't reflected in the browser window.
Nov 18 '05 #8

P: n/a
i have a similar problem, i can see the result in the debug view but the result does not get displayed on the web page

Any solution

Thanks. Karim.
Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.