Solved

External Javasctipt function  not finding object on page.

Posted on 2013-01-14
4
226 Views
Last Modified: 2013-01-15
Hi

I have a grid with a timer to force an AJAX refresh. I have an external JS page with a function to open a pop up. This all works fine.

I have added the following to stop the timer on pop up

    var AjaxTimer = $find('<%= tmrGridRefresh.ClientID %>');
    AjaxTimer._stopTimer();
   'pop up code here...

This doesn't work. The problem is the Var AjaxTimer is always null.

If I copy the function out of the external file into the actual page it works OK.

Why is the $find('<%= tmrGridRefresh.ClientID %>'); not working when its in the external fle

Andy
0
Comment
Question by:Andy Green
  • 2
  • 2
4 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 38774223
0
 
LVL 3

Author Comment

by:Andy Green
ID: 38774406
Thanks

So rather than use the $find to get the client ID, If I Know the ID form the page markup, can I use that?

Andy
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 38775040
That can work. You can also add the JavaScript variable AjaxTimer and the $find to the head of the aspx page. Or, follow the suggestion in the link I provided and make your js file an aspx file containing nothing but JavaScript and a @Page directive. That way it will be processed by asp.net at runtime.
0
 
LVL 3

Author Closing Comment

by:Andy Green
ID: 38777275
Thanks for answer and follow up.

Andy
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 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

26 Experts available now in Live!

Get 1:1 Help Now