I have a gridview
with the HeaderTemplate
and it contains a LinkButton
. When I click the button I want to open a link in new tab
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="lnkbtn" runat="server" OnClientClick="SetTarget();" OnClick="lbtn_Click">Topics</asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
........
</ItemTemplate>
My JavaScript
<script type = "text/javascript">
function SetTarget() {
document.forms[0].target = "_blank";
}
</script>
And the OnClick
event is
protected void lbtn_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/");
}
This is opening the link in new tab.
But I have other LinkButton
outside the gridview
for other processes such as Saving
the data, etc.,.
<asp:LinkButton ID="LinkButton1" runat="server">Save</asp:LinkButton>
But when I even click this button it is opening new tabs.How can I prevent them from opening in new tabs