Is it possible to call ASP.NET codebehind function from JavaScript.
|
I would prefer Muhammad Akhtar PageMethod approach. Just one short note: You don't need the scriptmanager. The scriptmanager only generates the javascript proxy methods for you. If you already have JQuery on your page, you can forget about the scriptmanager and write something like this on your page instead:
this assumes that you have a link with the ID AjaxLink on your page as well as a div with the id content that shows the result. The benefit is that you save 30kb javascript compared between jquery and the injected scripts by the scriptmanager |
||||
|
yes, you can make web method like..
and then call in javascript like..
this also need to add
|
|||||||||||
|
cs function
in script cs fucnction calling using scriptmanager
|
||||
|
No, it is not possible to call ASP.NET code behind function from Javascript directly. ASP.NET code behind executes on the server in the context of the ASP.NET worker process. Javascript is executed on the client in the context of the client's browser. The only way Javascript could trigger execution of ASP.NET code behind is through making an AJAX call from the Javascript to the server. |
|||||||||||||
|
You can make use of |
|||
|
If you are working on a non-Ajax project, you can try System.Web.UI.ICallbackEventHandler. Samples here:
|
||||
|