How can I call a method in the code behind from a jQuery post in asp.net webforms?
In MVC it’s simple, I just do this:
$.post("/MyController/MyMethod", { data: somedata; }, function(result) { alert(result); });
but I can’t figure how what to put for the first parameter if I wanted to call a method in the code behind in webforms… for example, if I have a method called doSomething() is there a way to stick some location in there so that it will call doSomething() and return data to the callback?
The first parameter is just the URL, so you have to expose your code-behind method as a web service. You can use a page method or a dedicated web service.
Page method example: http://www.dotnetcurry.com/ShowArticle.aspx?ID=109&AspxAutoDetectCookieSupport=1