Like i said, an event handler in javascript cannot be the name of the file.
And 'mouse.js' is the name of a file. Hence this cannot work!!! Client side
javascript cannot know about files on the server. So it cannot go grab
mouse.js when it needs it. All it can do is call functions - and these
functions have to be on the current page.
If you are including mouse.js, then whatever code is in it, will just run
when the page loads, since you don't have it in a function.
I think you should brush up on how javascript works, since it doesn't sound
like you understand what role it plays in a page, and how it should be used.
"Steven" <counterball_20122@_hotmail.com> wrote in message
news:eF**************@tk2msftngp13.phx.gbl...
Hello Marina,
I'm trying to execute the code in javascript file, when the user clicks on
a button .
I added ZoomInImgBut.Attributes.Add("onClick", "mouse.js"); in code
behind page on page load event.
So, javascript should be running whenever the user clicks on the Zoom In
button. But the problem is javascript is running on the page load itself.
Any suggestions
Regards
Steven
"Marina" <so*****@nospam.com> wrote in message
news:ua**************@TK2MSFTNGP15.phx.gbl... Javascript can't execute a file. What would that mean? It can execute
functions. If you include a js file that has a function, then it can call
that function since it becomes part of the page.
"Steven" <counterball_20122@_hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl... Hello,
I have 3 files --
1. mainform.aspx
2. mainform.aspx.cs
3. mouse.js
mainform.aspx contains a image button ("zoominimgbut") which will
exceute C# code, whenever the user clicks on it. mainform.aspx.cs is the
code behind for mainform.aspx. Mouse.js contains javascript code which
needs to executed ONLY when the user clicks on "zoominimgbut". But the
problem is the javascript code is executing all the time (meaning even
if the user doesn't click on the image button) . I added this line to
the page load / zoominimgbut on click events :
ZoomInImgBut.Attributes.Add("onClick", "mouse.js"); But its not working.
Any help would be greatly appreciated
Regards
Steven