Solved

2 javascript code in the same webpage (first from Master Page, second from UserControl)

Posted on 2004-09-19
1
377 Views
Last Modified: 2013-12-16
Hi Experts,

I use RegisterStartupScript function to add javascript to my webpage from this webpage and also from one of my usercontrols.
The problem is that I use the javascript event "onmousemove" in both scripts.

So the result is:

<script language='javascript'>
... my javascript code
document.onmousemove =movefrommaster;
</script>
<script language='javascript'>
... my javascript code
document.onmousemove =movefromusercontrol;
</script>

I can't manage my javascript code as I want if I use a usercontrol.

Thanks in advance for any help.
0
Comment
Question by:noulouk
1 Comment
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
ID: 12095338
Hi noulouk,

why don't you use a javascript function that will pass as a parameter which is the caller ( master page or user control ) and depends on this value to execute the certain code. the registering of call to this function will be executed again with RegisterStartupScript but will cover the needed functionality

<script language="Javascript">
function callOnMouseMove ( caller )
{
 if ( caller )
  document.onmousemove = movefrommaster;
 else
  document.onmousemove = movefromusercontrol;
}

</script>

and with the registerstartupscript will call from master page like
callOnMouseMove( true )
and from user control
callOnMouseMove ( false )
B..M
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now