Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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
 
Share this answer
 
Comments
Member 7946563 14-Jul-11 3:44am    
Thanks a lot yourcode works fine
Member 7946563 14-Jul-11 4:31am    
One more help how to set the header for that window

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900