I have a grid which has a select button to select row data.On select button click i want to open another page in another tab.
javascript function:=
function opentab() {
var vrn = document.getElementById("<%=hdnvrno.ClientID%>").value;
window.open("ABC.aspx?vrno=" + vrn + "", "_blank");
}
ASPX:=
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:HiddenField ID="hdnvrno" runat="server" Value="" />
<asp:GridView ID="GridView1" runat="server">
<columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnSelect" runat="server" Text="s" Width="7px" CommandName="Select" CommandArgument='<%# Eval("VAL") %>' />
</ItemTemplate>
</asp:TemplateField>
CODE BEHIND :=
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
string VAL= e.CommandArgument.ToString();
Button btnlink = (Button)e.CommandSource;
hdnvrno.Value = VAL;
btnlink.Attributes.Add("OnClick", "opentab();");
}
}
when i firstly click on select button the function js function is not called when i click it secondly it gets called.Whats the problem i m not able to understand.
Help me plzzz.