如何打开一个新窗口 [英] How to open a new window

查看:78
本文介绍了如何打开一个新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我喜欢在我的项目中打开一个新窗口.我在项目中使用两个面板当我单击gridview(panel1)中的"Viewdocument"链接时,它应该显示打开该文件的窗口.但是在我的代码中,它不起作用可以帮助我解决此问题.这是代码.

Hi,
I like to open a new window in my project. I am using two panels in my project When I click the "Viewdocument" link in gridview(panel1) it should display the window to open that file. But in my code its not working can any one help me to solve this issue. Here is the code.

if (myReader.Read())
                {
                    myReader.Close();
                    openWIndow("fr_OpenFile.aspx", "", fileName);
                    Linkbutton_ModalPopupExtender.Show();
                    //OpenMyFile();
                }
                else
                {
                    myReader.Close();
                    Message("Cannot open selected file");
                    Linkbutton_ModalPopupExtender.Show();
                    return;
                }
                con.Close();
                //OpenMyFile();
            }
            else
            {
                Message("File not found");
                Linkbutton_ModalPopupExtender.Show();
            }
        }
        catch (Exception ex)
        {
            lblmsg.Text = ex.Message;
        }
    }
 private void openWIndow(String FileName, String WindowName, String qString)
    {
        String fileNQuery = FileName + "?value=" + qString;
        String script =  @"<script language=""javascript"">"  + "window.open(" + fileNQuery +  WindowName + "," + "menubar=Yes,toolbar=No,resizable=Yes,scrollbars=Yes,status=yes" + " );" + "</script>";
        ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", script);
    }



在此先感谢



Thanks in Advance

推荐答案



如果有帮助,请尝试以下示例:

Hi,

Try this example if it could help:

   OpenAWindow(this, "fr_OpenFile.aspx");

public static void OpenAWindow(System.Web.UI.Page page, string url)
 {
    
     StringBuilder algemScript = new StringBuilder();
     algemScript.Append("javascript:");
     algemScript.Append("window.open(''");
     algemScript.Append(url);
     algemScript.Append("'',\"\",\"height=600,top=0,");
     algemScript.Append("status=1,menubar=0,resizable=1,location=0,scrollbars=1\");");
     string myScript = algemScript.ToString().Trim();      
     ScriptManager.RegisterStartupScript(page, page.GetType(), "subscribescript", myScript, true);
 }




请记住,如果有帮助,请将其标记为答案;如果没有帮助,则将其取消标记.

问候,

代数




Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Regards,

Algem


这篇关于如何打开一个新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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