Friday, September 21, 2018

What is a web method at web forms?

It is for ghetto web services. This has this example:

[System.Web.Services.WebMethod]
public static string search()
{
   return "worked";
}

 
 

To hit this from JavaScript you would call out to the URL of your .aspx page and chase the URL with "/search" on the end. That should let you pull the "worked" out into the JS implementation via AJAX. The same StackOverflow thread I reference above suggests you need a ScriptManager and that EnablePageMethods="true" should be an inline parameter in the ScriptManager.

No comments:

Post a Comment