Is there a way to click a link programatically, so that it has the same effects as if the user clicked on it?
Example:
I have an ASP.NET LinkButton:
<asp:LinkButton id='lnkExport' runat='server' CssClass='navclass'>Export</asp:LinkButton>
I have a link on a sidebar directing to the .aspx page that has this linkbutton on it. For various reasons I can’t have the code for the LinkButton executed until the page has refreshed — so I am looking for a way to force-click this LinkButton in my code once the page is completely loaded. Is there a simple/doable way to accomplish this? If it involves triggering an event, please provide a code sample if you can. Thanks.
Rashack’s post show’s how to do it. You can just do it in javascript.
If you want this to fire after some other event, you can add code in c# to add a call to that function on the client side when the page loads.