Click here to Skip to main content
15,923,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my anchor tag:

<a id="hidden_link" runat="server">


and function :

XML
function Call() {

            $("#ctl00_ContentPlaceHolder1_hidden_link").trigger('click');
            alert('hi');
           
        }
Posted
Comments
[no name] 5-Dec-15 0:57am    
Are you sure about your ID of anchor tag?

Secondly put an alert before trigger click called to make sure that function is called.

Instead of triggering click anchor tag i used this and it works,

JavaScript
function Call() {
          var href = $('#ctl00_ContentPlaceHolder1_hidden_link').attr('href');
          window.location.href = href;

      }
 
Share this answer
 
Now seeing your code, some things needs to be adjusted..

When accessing a server object from javascript, always use <%= ObjectName.ClientID%> because your parent control name can chnage and it will cause problems trying to find whats gone wrong.
Update your code to this simple line


JavaScript
function Call() {         
$("#<%= Hidden_Link.ClientID%>").click();
            alert('hi'); 
}


OR use this

JavaScript
$("#<%= Hidden_Link.ClientID%>").on("click", function() {
  alert('hi');
});
$("#<%= Hidden_Link.ClientID%>").trigger("click");


REPORT IF YOU STILL HAVE ANY ISSUE ELSE MARK AS ANSWER
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900