I want to display the webpage as a modal popup.
Response.Write("<script type='text/javascript'>detailedresults=window.showModalDialog('NewFile.aspx','Data','left=(screen.width) ? (screen.width - 800) / 2 : 0,top=(screen.height) ? (screen.height - 700) / 2 : 0,width=1000, height=500, toolbar=no, menubar=no, titlebar=no, location=no, addressbar=no');</script>");
While using the above code. I am able to display web page as modal popup, but the issue is that it also opens a third window which is a web page of same name and not a modal popup.
Please help me in resolving this issue. Thanks in Advance.
Rather than writing the script out to the response use RegisterStartupScript
instead:
Page.ClientScript.RegisterStartupScript(this.GetType(),
"detailedresults",
"<script type='text/javascript'>detailedresults=window.showModalDialog('NewFile.aspx','Data','left=(screen.width) ? (screen.width - 800) / 2 : 0,top=(screen.height) ? (screen.height - 700) / 2 : 0,width=1000, height=500, toolbar=no, menubar=no, titlebar=no, location=no, addressbar=no');</script>");