![]() |
Running server-side code from a javascript click event
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, |
Re: Running server-side code from a javascript click event
~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". |
Re: Running server-side code from a javascript click event
"~J~" <anonymous@discussions.microsoft.com> wrote in message
news:0FAFDB86-81E6-4CF7-93EA-2AC20418521F@microsoft.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 |
Re: Running server-side code from a javascript click event
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~" <anonymous@discussions.microsoft.com> wrote in message news:0FAFDB86-81E6-4CF7-93EA-2AC20418521F@microsoft.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, |
| All times are GMT. The time now is 11:49 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.