after the user will click the linkbutton in gridview i just want to have a window pop up page
I test your code on my side, it works fine. Please check if the popup page is blocked by your browser. You can find how to configure web browsers to allow popup windows in the following link.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
31 Points
296 Posts
ClientScript.RegisterStartupScript is not working in gridview
Dec 12, 2016 12:46 PM|paminchever|LINK
ClientScript.RegisterStartupScript is not working in gridview
here's my code:
<gridiview>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="linkbtnedit" runat="server" Text="Print" CssClass="btn btn-success"
OnClick="Button_PRT" CausesValidation="False"
CommandName="Select" OnClientClick="aspnetForm.target ='_blank';setTimeout('fixform()', 500);"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</gridview>
protected void Button_PRT(object sender, EventArgs e)
{
LinkButton btn = sender as LinkButton;
GridViewRow row = btn.NamingContainer as GridViewRow;
string idno = GridView1.DataKeys[row.RowIndex].Values[0].ToString();
string srno = GridView1.DataKeys[row.RowIndex].Values[1].ToString();
Session["IDNO"] = idno;
Session["SRNO"] = srno;
ClientScript.RegisterStartupScript(this.Page.GetType(), "", "window.open('page.aspx','Graph','height=400,width=500');", true);
}
All-Star
52201 Points
23274 Posts
Re: ClientScript.RegisterStartupScript is not working in gridview
Dec 12, 2016 01:47 PM|mgebhard|LINK
What does not working mean exactly? What do you expect to happen? Have you tried debugging the code?
Does idno and srno contain the expected values. What does page.aspx do?
Member
31 Points
296 Posts
Re: ClientScript.RegisterStartupScript is not working in gridview
Dec 13, 2016 05:19 AM|paminchever|LINK
after the user will click the linkbutton in gridview i just want to have a window pop up page
Contributor
6490 Points
2525 Posts
Re: ClientScript.RegisterStartupScript is not working in gridview
Dec 13, 2016 06:03 AM|Jean Sun|LINK
Hi paminchever,
I test your code on my side, it works fine. Please check if the popup page is blocked by your browser. You can find how to configure web browsers to allow popup windows in the following link.
https://www.isc.upenn.edu/how-to/configuring-your-web-browser-allow-pop-windows
The result on my side:
Best Regards,
Jean
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.