How to open the new window in C#
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
There are many ways. You can do this by simply using target="_blank" in asp.net hyperlink control. You can do this using window.open() function in JavaScript. You can even register this JavaScript code from asp.net code behind. All detail is discussed here in How to open new window in asp.net, c# using JavaScript? Follow http://dotnetspidor.blogspot.com/2009/01/open-new-window-in-aspnet-web-page_28.html.
read this: http://www.velocityreviews.com/forums/t112713-open-new-browser-window-on-server-side-button-click.html
精彩评论