Hi,
I'm relatively new to the new avtar of AJAX. I've used the Ajax.dll in my previous application to make an AJAX call.
Now my issue is. How do i call a function on my code behind page , from my client side javascript. To elaborate this consider the following.
I'm creating a new ASP.NET AJAX Web Site.
I've Defaul.aspx with following controls.
1. a button.
2.a dropdown.
In my Default.vb page i've a function FillComboValues() that returns a string.
No on clicking Button i wanna run the FillComboValues() function on my code behind.( I DONT WANT TO USE UPDATEPANEL.)
I've read many articles on net to solvemy problem but every example describes how to access a webservice method. none of them have described how to access a pagemethod.
Pls help me out with this ...
Thanks in advance.
----
In previous version of ajax , we needed to register the server side function using <Ajax.AjaxMethod()> _ . isn't there an equivalent way of registering the function.?
Hi,
Same problem for me, plz let me know whether you have found a solution for this or not?
Thanks
Hi, you can only call static functions of codebehind from javascript normally. Create a static function in codebehind and in javascript just call it in the following way:
say your static method is returning some string value, then in javascript you have to write,
var returnedValue = <% ="'" + ReturnHello() + "'" %>
In order to call a function on codebehind you can use either a WebService or an static method. I had the same problem and i used static methods because it′s more like Ajax.AjaxMethod, The first thing to do is to add to the scripmanager the following line EnablePageMethods="true" and then in code behing put [WebMethod] in front of every method you want to use. To call them from your client script, just use PageMethods.[your method name] and you should be good to go....
i am speaking about the code behind file of aspx page (not asmx-webservice). You can not use [WebMethod] in codebehind file.
In previous version of ajax , we needed to register the server side function using[Ajax.AjaxMethod()] {in codebehind} . isn't there an equivalent way of registering the function.?
Pleaes let me know if you have any thing equivalent to this?
SaiTej:
i am speaking about the code behind file of aspx page (not asmx-webservice). You can not use [WebMethod] in codebehind file.
In previous version of ajax , we needed to register the server side function using[Ajax.AjaxMethod()] {in codebehind} . isn't there an equivalent way of registering the function.?
Please let me know if you have any thing equivalent to this?
Alternate method inAjax Extensions is putting the control (for ex:button) in Update panel. All the events that u write for this control are async.
So no need to declare explicitly[Ajax.AjaxMethod()]
asj:
Equivalent way inAjax Extensions is putting the control (for ex:button) in Update panel. All the events that u write for this control are async.
So no need to declare explicitly[Ajax.AjaxMethod()]
No comments:
Post a Comment