Running server-side code from a javascript click event

G

Guest

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,
 
U

user

~J~ said:
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".
 
J

John Saunders

~J~ said:
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.
 
J

John Timney \(Microsoft MVP\)

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~ said:
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.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top