call a routine from Javascript

R

RicercatoreSbadato

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

Laurent Bugnion

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top