Function from the server side of the calls from the client side javascript

Possible duplicates:
how to call a server side function from the client side - asp.net
Calling ASP.NET Code Behind a Function from Javascript
ASP.NET server-side method invocation via jQuery

Hi guys, When loading an aspx page, how can I call a server-side method with client-side code? Can one show an example?

-one
javascript c #
source share
4 answers

You will need ajax for this one way or another. Either use ASP.NET's built-in "page methods", or push it up yourself; it is best to use something like jQuery to make the javascript part less painful for you.

0
source share

You can execute this request through Ajax. Since you are using asp.net, this is a good starting point for some great Ajax JavaScript libraries .

Here's also a simple example of how to make a simple Ajax request.

function sampleAjaxReq(){ var xmlhttp=new XMLHttpRequest(); xmlhttp.open("POST","resource.asp",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("pname1=value1Henry&pname2=value2"); } 
0
source share

If you are working on a project other than Ajax, you can try System.Web.UI.ICallbackEventHandler.

Samples here:

http://msdn.microsoft.com/en-us/library/ms178210%28VS.80%29.aspx

http://www.ajaxmatters.com/2006/05/using-icallbackeventhandler-in-asp-net/

0
source share

You can also chat with web services.

0
source share

All Articles