I am trying to access a page method from centralized module.
-
I tried putting it in a master page it didn’t work
-
I tried putting it in a web service and did the following
-
added its path to the script manager that its existed in the master page
-
added a web service reference to the project
-
configured the web.config for the page methods
-
Also didn’t work (kept telling me that “PageMethods is not defined” <- JavaScript error)
- tried to access the page methods through http request from Javascript, got server error response (500)
What am I missing?
I followed example #2 at this link and it worked fine (the samples appear to be broken however): http://www.asp.net/Ajax/Documentation/Live/tutorials/ExposingWebServicesToAJAXTutorial.aspx
Here are the steps I took:
1) create a basic .asmx web service with ‘HelloWorld’ method
2) add the attribute [ScriptService] to the ‘HelloWorld’ method (and any methods in the web service that you want to call from your page script)
3) add a ScriptManager to the page, referencing the web service, and including InlineScript=”true”
4) call the page from Javascript like this:
The fact that you’re getting a 500 error tells me that there’s an error in your web service. I would start here: can you open your web service URL in a browser successfully, and invoke its methods?