简体   繁体   English

在网格视图按钮上打开新窗口,单击aspx.cs页面?

[英]Open new window on grid view button click in aspx.cs page?

I am working on aspx.cs page.When i will click on grid button column,then it should be take some data from present page to new page and open it in to new window without destroy present window. 我在aspx.cs页面上工作。当我单击网格按钮列时,应该将一些数据从当前页面移到新页面,然后在不破坏当前窗口的情况下将其打开到新窗口。

   protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
    if (e.CommandName == "Trans")
    {

      Response.Redirect("APIwiserecharge.aspx?DisplayID=" +
       objdl.Encode(e.CommandArgument.ToString()));
    }

  }

To open a new window from codebehind you need to use javascript. 要从后台代码打开新窗口,您需要使用javascript。 You need to handle click event with javascript. 您需要使用javascript处理点击事件。 You can try this code for your codebehind: 您可以为自己的代码尝试以下代码:

  protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
    if (e.CommandName == "Trans")
    {

       string url = "APIwiserecharge.aspx?DisplayID=" +objdl.Encode(e.CommandArgument.ToString());

       string s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";

        ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);
    }

  }

尝试这个..

ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "javascript:window.open( 'APIwiserecharge.aspx','_blank','height=600px,width=600px,scrollbars=1');", true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM