Running server-side code from a javascript click event

Discussion in 'ASP .Net' started by =?Utf-8?B?fkp+?=, Jun 8, 2004.

  1. Hi everyone

    I'm positive this is possible, just never needed it until now and I don't have a clue where to start

    I have an XML document that is attached to an XSL style sheet, within this XSL there is some javascript commands that are attached to certain HTML controls

    What I want to do is when the user clicks on an HTML generated code (because I can't generate server-side controls in XSL), this runs a subroutine which is server-side

    How can I force a control to run something server-side, and can I pass parameters to it

    Many thanks,
    =?Utf-8?B?fkp+?=, Jun 8, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?fkp+?=

    Guest

    ~J~ wrote:
    > Hi everyone,
    >
    > I'm positive this is possible, just never needed it until now and I don't have a clue where to start.
    >
    > I have an XML document that is attached to an XSL style sheet, within this XSL there is some javascript commands that are attached to certain HTML controls.
    >
    > What I want to do is when the user clicks on an HTML generated code (because I can't generate server-side controls in XSL), this runs a subroutine which is server-side.
    >
    > How can I force a control to run something server-side, and can I pass parameters to it?
    >
    > Many thanks,


    One idea is to do a submit for the form from the javascript code
    (document.forms[0].submit() will do the trick). You will have to call
    your method from the page load event if you decide that the javascript
    on the client did the post back. You can use a html hidden control to
    pass parameters.

    Another idea is to use a very small image submit control (1x1 pixels)
    with a transparent color and from the script to enforce a click on this
    submit button (theSubmit.click() will do the trick - be aware of the
    browser compatibilities here). Has the advantage that it will run the
    server side control onclick event but the disadvantage of a "hack".
    , Jun 8, 2004
    #2
    1. Advertising

  3. "~J~" <> wrote in message
    news:...
    > Hi everyone,
    >
    > I'm positive this is possible, just never needed it until now and I don't

    have a clue where to start.
    >
    > I have an XML document that is attached to an XSL style sheet, within this

    XSL there is some javascript commands that are attached to certain HTML
    controls.
    >
    > What I want to do is when the user clicks on an HTML generated code

    (because I can't generate server-side controls in XSL), this runs a
    subroutine which is server-side.
    >
    > How can I force a control to run something server-side, and can I pass

    parameters to it?

    You can't actually "run" anything server-side, but you can have your
    client-side code do a postback.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 8, 2004
    #3
  4. You would have to rsort to something called a web service behaviour which
    allows you to call remote methods from Javascript without doing a page
    refresh.

    You should be able to find eamples on google.

    --
    Regards

    John Timney
    Microsoft Regional Director
    Microsoft MVP


    "~J~" <> wrote in message
    news:...
    > Hi everyone,
    >
    > I'm positive this is possible, just never needed it until now and I don't

    have a clue where to start.
    >
    > I have an XML document that is attached to an XSL style sheet, within this

    XSL there is some javascript commands that are attached to certain HTML
    controls.
    >
    > What I want to do is when the user clicks on an HTML generated code

    (because I can't generate server-side controls in XSL), this runs a
    subroutine which is server-side.
    >
    > How can I force a control to run something server-side, and can I pass

    parameters to it?
    >
    > Many thanks,
    John Timney \(Microsoft MVP\), Jun 8, 2004
    #4
    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. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Replies:
    2
    Views:
    6,487
    rick74
    May 27, 2008
  2. nick
    Replies:
    3
    Views:
    3,183
    Eliyahu Goldin
    Dec 15, 2004
  3. =?Utf-8?B?Vk1J?=
    Replies:
    2
    Views:
    807
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Oct 9, 2006
  4. Aymer
    Replies:
    1
    Views:
    387
    Alvin Bruney
    Sep 19, 2003
  5. Guest

    Fire server side event before client side event

    Guest, Mar 17, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    587
    Ken Cox [Microsoft MVP]
    Mar 18, 2005
Loading...

Share This Page