473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Add Javascript function

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
Nov 16 '05 #1
4 10659
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

Nov 16 '05 #2
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


Nov 16 '05 #3
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



Nov 16 '05 #4
Steven,

It is completly as Marina tells,

Maybe when you add to your JS file in the beginning
Function Steven()
{
..
..
And at the end
}

Than it will (maybe) work with that button click event
ZoomInImgBut.Attributes.Add["onClick"] = "javascript:Steven();";

Assuming that what you tell now is exact as it is.

This all typed in this message withouth any test so watch typos or whatever

Cor
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.