call a routine from Javascript

Discussion in 'ASP .Net' started by RicercatoreSbadato, Sep 11, 2006.

  1. I'd like to call a method from a Javascript function.. how can I do?
    The method is in the codebehind..
    RicercatoreSbadato, Sep 11, 2006
    #1
    1. Advertising

  2. Hi,

    RicercatoreSbadato wrote:
    > 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
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    PhotoAlbum: http://www.galasoft-LB.ch/pictures
    Support children in Calcutta: http://www.calcutta-espoir.ch
    Laurent Bugnion, Sep 11, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KiwiBrian
    Replies:
    3
    Views:
    5,411
    KiwiBrian
    Nov 30, 2005
  2. gamename
    Replies:
    5
    Views:
    436
  3. Replies:
    2
    Views:
    740
    Alexey Smirnov
    May 14, 2007
  4. Bazil
    Replies:
    2
    Views:
    100
    Tad McClellan
    Dec 6, 2003
  5. Big Jay
    Replies:
    15
    Views:
    166
    robic0
    Mar 19, 2006
Loading...

Share This Page