call javascript

G

Guest

hey all,

i have a server-side button on my webform and was wondering if i can call an
external javascript that's in the same application direcory?
If so, can someone please show me the syntax?

thanks,
rodchar
 
K

Kevin Spencer

Put a reference to the .js file in the page HTML. Example:

<script type="text/javascript" src="myscript.js"></script>

Then just use Page.RegisterStartupScript or whatever means you want to add a
script to the page that calls a function or uses data in the external
JavaScript.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
 
G

Guest

i'm sorry, i wasn't clear on my OP. for the button.click event on the code
behind can i run the javascript from there? if so, how?
 
K

Kevin Spencer

i'm sorry, i wasn't clear on my OP. for the button.click event on the code
behind can i run the javascript from there? if so, how?

JavaScript is client-side. The only place you're going to be running it is
on the client. So, my answer is the best you're going to get: You can add a
script to the client-side HTML on the server, and run it when the page gets
back to the client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
 

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

Similar Threads

dropdownlist and javascript 2
javascript help please 2
javascript combo box 2
a little help please... 1
how to: please 2
immediate window just showing {...} 1
javascript values to array 4
client side ? 1

Top