We’re redevloping a major section of our website and rather than use a 90k AJAX file I’d rather use a 19K jquery script.
I’ve seen the following articles;
- Using jQuery for AJAX with ASP.NET
Webforms - jQuery autocomplete in ASP.NET webforms?
- Autocomplete with ASP.Net MVC and
JQuery
The thing I don’t get is how to do a postback to a specific method in either the code behind or another class.
I know in ASP.NET-MVC I can post back to a controller / action. How do I call a particular method in WebForms?
Something along the lines of; $.post(“class and action“, ( param:value}……
Any thoughts, code etc???
It is very easy to call specific methods in code-behind. Here is nice article with all the details by Dave.
Simply declare a method like this:
This is all you need in jQuery:
Caveats:
WebMethodmust be on a static methodJSON.stringify(yourDataObject)), will be deserialized according to method parametersmsgis the response, the return result from your method is in the propertymsg.d