(Ajax) Loading a web service after async postback

E

elado7

Hey

I'm trying to load a webservice after an async postback in the
following way:

ScriptManager.GetCurrent(Page).Services.Add(new
ServiceReference("WS.asmx"));

in order to have a client-side access to its web methods.

When doing it with normal postback or in the first load of the page,
it works, but if I load it manually from within a code after an async
postback, the code doesn't appear to download to the browser.
I load if from the code since it comes from a dynamically loaded user
control (ascx loaded thru Page.LoadControl).

So, I tried to load it like a javascript include in the following way:

ScriptManager.RegisterClientScriptInclude(Page,Page.GetType(),"key","file.asmx/
js");

However, since the source is missing the
'Sys.Application.notifyScriptLoaded()' call, the ajax framework yelled
at me :
Microsoft JScript runtime error: Sys.ScriptLoadFailedException:
The script '...' failed to load. Check for:
Inaccessible path. Script errors. (IE) Enable 'Display a
notification about every script error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().

So, finally I tried to load the script's content and register it as a
script block. Bah. The asmx is protected thru authorization.

My solution could be allowing anonymous access to the asmx, or make a
js function that'll document.createElement a script and inject it to
the <head>, and register it as a script block.
But I'm asking -- isn't there any other clean way? Can't I just
disable the notifyScriptLoaded?

Thanks
Elad
 

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
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top