Solved

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

Posted on 2004-09-19
1
381 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…

816 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

8 Experts available now in Live!

Get 1:1 Help Now