在gridview上按“编辑"按钮时,如何打开另一个页面? [英] How can I open another page when pressing the Edit button on a gridview?

查看:92
本文介绍了在gridview上按“编辑"按钮时,如何打开另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C.asp.net中有一个Gridview控件.

I have a Gridview control in asp.net with C#.

在我的应用程序中,当我从Gridview按下编辑按钮时,我需要在另一个窗口中打开信息.此时,我使用"Response.Redirect("..")",但它在同一窗口中打开.

In my application when I press the edit button from Gridview I need to open the information in another window. At this moment I use 'Response.Redirect("..")' but it opens in the same window.

我尝试过:

 protected void OutputGridView_RowEditing(object sender, GridViewEditEventArgs e)
        {
            outputGridView.EditIndex = e.NewEditIndex;
            GridViewRow row = outputGridView.Rows[outputGridView.EditIndex];

            string url = "http://localhost/MyPage.aspx";
            Response.Write("<script>");
            Response.Write("window.open('" + url + "')");
            Response.Write("<" + "/script>")

            e.Cancel = true;
        }

但是没有运气.

有人知道最好的方法吗?

Does anyone know the best way to do this?

推荐答案

此代码将在新窗口中打开窗口.为此,您需要使用ScriptManager

This code will open the window in new window. for this you need to use the ScriptManager

string BrowserSettings = "status=no,toolbar=no,menubar=no,location=no,resizable=no,"+
                                        "titlebar=no, addressbar=no, width=600 ,height=750";
            string URL = "http://localhost/MyPage.aspx";
            string scriptText = "window.open('" + URL + "','_blank','" + BrowserSettings + "');";
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "ClientScript1", scriptText, true);

这篇关于在gridview上按“编辑"按钮时,如何打开另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆