I am facing an issue with an ajaxcontrol that contains a tab panel and a grid view with LinkButtons. My goal is to open a new window when clicking the LinkButton, but instead of triggering a postback, I get redirected to the first panel in the tab control.
<ajaxcontrol:TabPanel ID="TabPnlDependents" runat="server">
<HeaderTemplate>
Dependents
</HeaderTemplate>
<ContentTemplate>
<table>
<tr>
<td>
<asp:GridView ID="DependentsGridView" DataSourceID="SqlDependentsGridView" AutoGenerateColumns="false" runat="server" DataKeyNames="PerId,PersonId" OnRowCommand="DependentsGridView_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Dependent ID">
<ItemTemplate>
<asp:LinkButton runat="server" ID="BtnDepenedentForm" Text='<%# Bind("PersonId") %>' CommandName="OpenDependentForm" CommandArgument='<%# DataBinder.Eval(Container,"RowIndex") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FullName" HeaderText="Name" />
<asp:BoundField DataField="Gender" HeaderText="Gender" />
<asp:BoundField DataField="RelationToMain" HeaderText="Relation" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
The code behind for handling the LinkButton Row Command event is as follows:
protected void DependentsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "OpenDependentForm")
{
int index = Int32.Parse(e.CommandArgument.ToString());
GridViewRow SelectedRow = DependentsGridView.Rows[index];
String RefId = DependentsGridView.DataKeys[index].Values[0].ToString();
String DependentId = DependentsGridView.DataKeys[index].Values[1].ToString();
string url = "DependentForm.aspx?DependentId=" + DependentId + "&PerId=" + PerId;
string script = "window.open('" + url + "', 'popup_window1','width=700, height=700, left=50, top=100, resizable=yes');";
this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "script", script, true);
}
}
Despite successfully opening the url
directly on my page, I continue to face the redirect issue when using the LinkButton.