如何使用GridView On RowCommand事件打开新窗口
How to open a new window by using GridView On RowCommand Event?
我有一个asp GridView,我正在使用RowCommand,并从这个页面获取一些值到另一个页面,我想在新窗口中打开该页面。
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Trans")
{
Response.Redirect("APIwiserecharge.aspx?
DisplayID="objdl.Encode(e.CommandArgument.ToString()));
}
}
在.aspx页面上,我使用了这个。
<asp:TemplateField HeaderText="APIDetails" ItemStyle-Width="200px">
<ItemTemplate>
<asp:LinkButton ID="trans" runat="server"CommandName="TransText="Details"
CommandArgument = '<%#Eval("DisplayID") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
请尝试使用以下代码片段。
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Trans")
{
Response.Write("<script>window.open('APIwiserecharge.aspx?DisplayID=' + objdl.Encode(e.CommandArgument.ToString()) ,'_blank');</script>");
//OR
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow1", "window.open('APIwiserecharge.aspx?DisplayID=" + objdl.Encode(e.CommandArgument.ToString()) + "');",true);
//OR
Page.ClientScript.RegisterStartupScript(GetType(), "OpenWindow1", "window.open('APIwiserecharge.aspx?DisplayID=" + objdl.Encode(e.CommandArgument.ToString()) + "');", true);
}
}
相关文章:
- GWT获取新旧窗口大小
- 如何在新标签/窗口中编写文本文档
- 如何在鼠标悬停在另一个图像/链接上时显示新图像/窗口
- 从服务器 c# 打开 Outlook 新邮件窗口
- 获取用户输入以设置新的窗口参数
- 为什么我不能创建新的窗口实例
- 在c中按下一个按钮,打开两个新的窗口/选项卡(不同的外部站点)
- 在新浏览器/窗口上单击提交按钮后打开PHP操作
- 如何恢复窗口,而不是打开一个新的窗口,如果它有相同的url(仍然从上一个打开)
- 如何在不制作另一个新选项卡或新浏览器窗口的情况下在同一网页中播放MPG视频/音频文件
- 如何打开一个新的窗口/选项卡没有用户的干预,而不让它被阻止
- 打开所有链接不是我的网站的一部分,在新的窗口与jquery
- 打开一个新的窗口,而浏览器没有给出警告,这是一个弹出
- 在新的窗口jquery功能不工作
- 如何使图标出现在一个新的窗口
- 如何重定向到一个新的窗口后,点击选择关于html的选项
- 如何强制电子邮件链接打开在新的窗口
- 显示更多的信息悬停在一个新的窗口,如在facebook
- 如何使用谷歌签名与重定向,而不是一个新的窗口
- 在新的窗口打开页面,没有弹出阻止使用JavaScript目标_blank