Andy Green
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Thanks for answer and follow up.
Andy
Andy
ASKER
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