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