JavaScript Reference with Master Pages

Posted on 2009-02-21
Medium Priority
Last Modified: 2012-05-06
So, I'm still figuring out this JavaScript stuff.

Referencing another question, code posted below.

What if my imgCtrl is on a page that uses the MasterPage, and my JavaScript is on the MasterPage? Is there any way to reference it in that manner?
<script type="text/javascript">
   var imgControlId = "<%= imgCtrl.ClientID %>";
in your javascript function
image = document.getElementById(imgControlId);
image.href = url;

Open in new window

Question by:veruthandai
1 Comment
LVL 12

Accepted Solution

CB_Thirumalai earned 2000 total points
ID: 23702810
Sure you can reference the control in page that user MasterPage and you can place the javascript in the MasterPage.  The only thing is both should have the same path.  If it isn't then, have the javascript in the Content page inside the content tag, as there will be issue loading the .js file if the content page is located in another folder.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 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