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. Advertisements

  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. Advertisements

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,607
    KiwiBrian
    Nov 30, 2005
  2. gamename
    Replies:
    5
    Views:
    538
  3. Replies:
    2
    Views:
    861
    Alexey Smirnov
    May 14, 2007
  4. Gregory A. Beamer

    HOW TO: Run JavaScript and a Server Side Routine

    Gregory A. Beamer, Dec 7, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    457
    Gregory A. Beamer
    Dec 7, 2009
  5. Jimbo
    Replies:
    2
    Views:
    239
    Bob Barrows [MVP]
    Nov 16, 2006
  6. Bazil
    Replies:
    2
    Views:
    192
    Tad McClellan
    Dec 6, 2003
  7. Big Jay
    Replies:
    15
    Views:
    280
    robic0
    Mar 19, 2006
  8. Klaus
    Replies:
    1
    Views:
    556
    Klaus
    Jun 25, 2012
Loading...