call a routine from Javascript

  • Thread starter Thread starter RicercatoreSbadato
  • Start date Start date
R

RicercatoreSbadato

I'd like to call a method from a Javascript function.. how can I do?
The method is in the codebehind..
 
Hi,
I'd like to call a method from a Javascript function.. how can I do?
The method is in the codebehind..

Since JavaScript runs on the client (at least that's what I accept from
your question), and the code-behind on the server, the only way is to
have the client send a request.

A request can be sent invisibly using XmlHttpRequest, or visibly using a
postback. You can choose between POST and GET. GET means that you use
the URL to pass parameters to the server, for example:

http://www.domain.com/mypage.aspx?method=MyMethod&param=Hello

A POST request is typically sent using a form, and submitting it. That's
the easiest way, but you can also construct a POST request using
XmlHttpRequest.

On the server, you must evaluate the parameters of the request (for
example using the Request.QueryString or Request.Form collections), and
take the corresponding measures, in that case calling a method.

HTH,
Laurent
 
Back
Top