Triggering jQuery click() From ASP.NET Master Pages

Hello Experts -
I'm trying to wire up a code-behind-run click event for a DIV on an ASP.NET master page.  In searching for a solution the most common suggestion that I have seen is to create and hide (using CSS) a button control somewhere on the master page and then code up the jQuery (inside $(document).ready) something like this:
$('#div').click(function () {
   $('#HiddenButton').click();
});

Open in new window

This works fine on a non-master page but I can't get it to work on a master, regardless of where I put the jQuery code.  Is there some unique insight or a special technique that I need to know about to get this to work on a master page structure?  Thanks!

-- Rick
MinnRickAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaitu chaituCommented:
if you put alert in master pages.is it firing?
$('#div').click(function () {
alert("hi")
   $('#HiddenButton').click();
});

or try this;

$('#div').live('click',function () {
alert("hi")
   $('#HiddenButton').click();
});
0
chaitu chaituCommented:
have you tried this.

http://api.jquery.com/trigger/
0
Kiran SonawaneProject LeadCommented:
1) Check the view source (right click on browser & view source). Button you are hiding, the id of button should be "HiddenButton"
2) OR add class to button (CssClass='hidebutton') then your jquery function will look like
$('#div').click(function () {
   $('.hidebutton').click(); // OR $(".hidebutton").trigger('click');
});
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MinnRickAuthor Commented:
No luck with either on() or trigger() - thanks for the attempt chaituu.

Sona:  Yes!  The ID for the hidden button is different in the markup for the rendered (child) page than is specified in the master page from which it originated.  I'm assuming that the reason lies in the whole master/child page model somehow.  In any case, setting a CSS class for the hidden button and wiring it up the jQuery click() for the DIV worked perfectly.  Thanks very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.