Link to home
Start Free TrialLog in
Avatar of Andy Green
Andy GreenFlag for United Kingdom of Great Britain and Northern Ireland

asked on

External Javasctipt function not finding object on page.

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
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Andy Green

ASKER

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
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.
Thanks for answer and follow up.

Andy