Monday, June 3, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  148] [ 2]  / answers: 1 / hits: 30198  / 12 Years ago, wed, march 6, 2013, 12:00:00

I want to know all possible ways to trigger a button in jQuery, I tried this but it's not working,



$(#<%=btA.ClientID%>).trigger('click');


Note: its a ASP.Net button and what I want is to trigger button click so that it will trigger a code-behind click method of buttonA.


More From » c#

 Answers
48

Try this



$(#<%=btA.ClientID%>).click();


if it doesn't work try to alert this and check if it is getting accessed by JQ



alert($(#<%=btA.ClientID%>).length);


Have you registered the event with jquery in following manner



$(function(){
$(#<%=btA.ClientID%>).click(function(){
// your logic here
});
});


One more thing to confirm, are you loading this button directly on page load or you are having some page update panel which load it afterwords?



If yes then you should bind the event to button in following manner



$(document).on('click',#<%=btA.ClientID%>, function() {...});

[#79801] Tuesday, March 5, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isaacvalentinn

Total Points: 325
Total Questions: 120
Total Answers: 131

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
isaacvalentinn questions
Mon, Jan 18, 21, 00:00, 3 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
Wed, Sep 23, 20, 00:00, 4 Years ago
;