2011-07-14 194 views
-5

我喜欢在我的项目中打开一个新窗口。我在我的项目中使用两个面板当我点击gridview(panel1)中的“Viewdocument”链接时,它应该显示打开该文件的窗口。但在我的代码中,它不工作,任何人都可以帮助我解决这个问题。这是代码。如何在C中打开新窗口#

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); 
    } 

由于提前

+2

什么是您的案例中的“打开新窗口”?打开一个Aspx页面? –

回答

3

方法有很多种。你可以通过在asp.net超链接控件中简单地使用target =“_ blank”来实现。你可以在JavaScript中使用window.open()函数来做到这一点。你甚至可以从后面的asp.net代码注册这个JavaScript代码。所有的细节在这里讨论如何在asp.net中打开新窗口,C#使用JavaScript?按照http://dotnetspidor.blogspot.com/2009/01/open-new-window-in-aspnet-web-page_28.html