[英]Open new window on grid view button click in aspx.cs page?
我在aspx.cs頁面上工作。當我單擊網格按鈕列時,應該將一些數據從當前頁面移到新頁面,然后在不破壞當前窗口的情況下將其打開到新窗口。
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Trans")
{
Response.Redirect("APIwiserecharge.aspx?DisplayID=" +
objdl.Encode(e.CommandArgument.ToString()));
}
}
要從后台代碼打開新窗口,您需要使用javascript。 您需要使用javascript處理點擊事件。 您可以為自己的代碼嘗試以下代碼:
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.