Solved

External Javasctipt function  not finding object on page.

Posted on 2013-01-14
4
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

737 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