I am using C#.NET 2.0.
I have already called functions that are stored in external JavaScript file.However, the ,method currently used by me is like this
1) add the external JavaScript file reference
e.g.
2) call a local function on click event
onclick=”someFunction();”
This function(someFuction) is present within the design page
3) Then call the function in the external JavaScript file(say ABC()) from within this function.
This works, but there is the overhead of writing the someFunction each time.
Is there a way to call the function ABC() directly form button click ?
Thanks in Advance
Rohan, I guess you are talking about an ASP.NET web page with a JavaScript block in the header and another separate JavaScript file referenced from the page.
If the external JavaScript file is referenced correctly, you CAN directly call the function.
For example, say you have a JavaScript file named
external.jsreferenced. And lets assume it has a function namedExternalFunction()in it. You can call theExternalFunction()directly from you HTML or ASP.NET button like you usually call a function in the same file:Example:
Note that ASP.NET buttons use
OnClientClickfor JavaScript and HTML buttons useonclick