Can I use ajax to call c#?

can I use ajax to call C# code behind method?

Elad Benda at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Yes you can. With a little feature called page methods. Decorate your codebehind method with the [WebMethod] attribute and you can call it from your page via javascript and within your WebForms html. See this: http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx Also see http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/

gideon

Yes, you can. See http://www.rajeeshcv.com/2008/10/aspnet-ajax-calling-server-side-methods-from-client-side/. It requires putting a ScriptManager tag on your page, and decorating your methods with an attribute.

wsanville

You can do it with or without a script manager. I would suggest looking into the ajax method in jQuery (http://api.jquery.com/jQuery.ajax/) as well as these links: http://api.jquery.com/jQuery.post/ http://www.infinitelooping.com/blog/2011/05/20/using-jquery-ajax-to-call-web-methods/ http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/

Gary.S

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.