Hi wilq32,
I'll try out Option 2 (option 1 won't work as I don't know full name)
R.e. option 3, I haven't worked with JQuery before so wouldn't know where to start with this. Will feed back once Option 2 works
Thanks
Main Topics
Browse All TopicsHi
I have a usercontrol which is displayed either directly on a master page, or nested on other user controls displayed on a master page. I need some Javascript to find a button on this page. An example of ID may be
ctl00$contentMiddle$MyUser
There will only ever be one theButtonToFind .....but finding it is the problem.
Thanks in advance for Javascript to find the control. It is is found from a popup window, like this
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The option 2 is worst solution :) It means that it goes every all items on page and try to find proper name. It is always better if you can specify tag name (instead of getElementsByTagName('*') use a 'div' or 'span'), or at least starting point more precisely than a whole document.
There is an error in snippet there:
instead of getElementByTagName type getElementsByTagName
thanks for more help....I'm not sure if nearly there yet.....see javascript below of what is happening /what trying to do
part 1 (hardcoded full string of parent works) - javascript find button and executes code-behind
part 2a does nothing at click. The debug gives [Object] [Object]
part 2b throws error
almost there I hope
ok so first of all what jQuery returns is not a DOM object, but more like jQuery array of objects (you could say).
Function .click(func) in jQuery mean "attach event onclick to all items selected using jQuery selector, fire a func on that event".
Can you try do something like this:
var theRefreshBtn = $("[id$=theButtonToFind]",
theRefreshBtn.each(functio
alert($(this).attr('id'));
});
then we see if it finds anything that might be usefull for you
based on http://docs.jquery.com/Cor
var theRefreshBtn = $("[id$=theButtonToFind]",
theRefreshBtn.each(functio
alert($(this).attr('id'));
});
still no joy, neither of following give any alerts
var theRefreshBtn = $("[id$=btnRefreshListOfIt
theRefreshBtn.each(functio
alert($(this).attr('id'));
});
var theRefreshBtn = $("[id$=btnRefreshListOfIt
theRefreshBtn.each(functio
alert($(this).attr('id'));
});
(I have typed btnRefreshListOfItems correctly)
do you have any more suggestions?
solution eventually!
var theRefreshBtn4 = $("[id$=btnRefreshListOfIt
theRefreshBtn4.each(functi
//alert("trial 5...here!");
//alert($(this).attr('id')
var btnID = $(this).attr('id');
var btn = window.opener.document.get
btn.click();
});
Business Accounts
Answer for Membership
by: wilq32Posted on 2009-11-04 at 07:54:20ID: 25740568
You mean that you know only a part of ID name? or whole name?
lementName ');
Name('*'); test(name) ) return a[i];
1. If you know whole name:
document.getElementById('e
2. If you know only a part of an ID and cant do anything about this:
function findIdContains(name){
var a=document.getElementByTag
for (var i=0,l=i.length;i<j;i++)
if (a[i]&&a[i].getAttribute &&a[i].getAttribute('id').
return null;
}
3. If you can do something about this, then why you dont set a ClassName for it? And use for ex. a jQuery function to select classNamed elements:
$(".className");