I have a LinkButton, it works really well, but when I add a href to the LinkButton, it redirects me to the link without firing the OnClick function.
<asp:LinkButton target="_blank" ID="ad_main_form"
OnClick="ad_button_Click" runat="server"
CssClass="ad_main_panel" CausesValidation="False"
href="https://stackoverflow.com">
</asp:LinkButton>
How to fire OnClick and href together?
LinkButtonhas a property with namePostbackUrlinstead usinghrefplease use this property.To avoid all this hassle what I would have done is, call a
Response.Redirect('url')inside my click handler so it does both the jobs in a cleaner manner.Update
Unfortunately you cannot open in new tab using
Response.Redirect()method, but you can certainly writejavascriptcode to open the url in a new tab. See:Alternatively, you can simply do it like this: