Monday, March 26, 2012

Call Server Side Function from Javascript

I wan to call Serverside function from Javascript function . We can use it by using AjaxPro.dll Assembly.

Can anybody have an idea how can we do that in new AjaxAsp.net extensions. I dont want to use Webservice . just want to call the web page class fucntion from html page using javascript.

use PageMethods.

there's a tutorial for it under the /docs web services section (all the way at the bottom). Basically, you flag a public static method in your codefile with the WebMethodAttribute and then your javascript can find it by claling PageMethods.myMethodName(params,onsuccess,onfailure) where 'myMethodName' is the name of the method in your page's codefile, params are any parameters it needs, and onsuccess and onfail are js functions to handle those events. You also need to set your scriptmanager's property EnablePathMethods=true.


I have tried this already and its gives me PageMethod undefined Error. ANd i have not found any soln. except of third party
Well, PageMethods do work, so there's probably some small mistake in your code or configuration. Perhaps you could post a sample of one that fails?
My guess is a missing EnablePageMethods="true" on your ScriptManager, though as Paul pointed out, we're just guessing until we can see what you've tried.

No comments:

Post a Comment