470,590 Members | 2,288 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Running server-side code from a javascript click event

~J~
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,
Nov 18 '05 #1
3 1681
~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".
Nov 18 '05 #2
"~J~" <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
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
Nov 18 '05 #3
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~" <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
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,

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Chris Dugan | last post: by
1 post views Thread by walterbyrd | last post: by
11 posts views Thread by John Sheppard | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.