I'm trying to find an ajax.net extender element with a dynamically generated ID. I'm trying to wire up an event handler to close all ajax.net modal popups when 'escape' is pressed. I'm confused why one of these works and one does not.
$find('ctl00_MainContent_ucUserControl1_mpePopup'); //returns the element
$find('[id="ctl00_MainContent_ucUserControl1_mpePopup"]'); //returns null
The ultimate goal is to be able to find the element without hard wiring the ID into the selector:
$find('[id$="_mpePopup"]'); //return all elements that end with "_mpePopup"
I believe you'll find that the
$findoperation requires a single ID. Unless I am grossly mistaken, there is no pattern matching capability in it. (For additional information on$findand$get, see http://mattberseth.com/blog/2007/08/the_everuseful_get_and_find_as.html)You might consider populating a JavaScript variable with the known popup client ID, using the ever-helpful
<%= mpePopup.ClientID %>page literal binding syntax or some other method convenient to your situation. Below is a simple example of ASPX markup, wherempePopupis a member of the page class: