Page.RegisterStartupScript and Javascript question ...
Hi,
I'm using ASP.Net and trying to display a popup window using Page.RegisterStartupScript. I'm trying to pass the fully qualified path to the file that I want to open; however, I get an error when I try to do so: Cannot find 'file:///c:inetpubwwwrootsdimv2-1ReportsReportViewer.aspx... Make sure the path or Internet address is correct.
Here's my code:
VB Code:
Page.RegisterStartupScript("AssetsAssignedToUser", "<script>" & "window.open('" & Server.MapPath(Request.ApplicationPath) & "\Reports\ReportViewer.aspx','test','WIDTH=925,HEIGHT=600,TOP=10,LEFT=30,menubar,toolbar,scrollbars,resizable');" & "</script>")
All of the slashes are in the wrong place. :confused: What am I doing wrong?
Thanks!
Re: Page.RegisterStartupScript and Javascript question ...
Page.RegisterStartupScript("AssetsAssignedToUser", "<script language=JavaScript>" & "window.open(document.location.href + '/Reports/ReportViewer.aspx','test','WIDTH=925,HEIGHT=600,TOP=10,LEFT=30,menubar,toolbar,scrollbars,r esizable');" & "</script>")
Re: Page.RegisterStartupScript and Javascript question ...
What happens? What do you get? What is the URL of the opened window?
Re: Page.RegisterStartupScript and Javascript question ...
Quote:
Page.RegisterStartupScript("AssetsAssignedToUser", "<script>" & "window.open('" & Server.MapPath(Request.ApplicationPath) & "\Reports\ReportViewer.aspx','test','WIDTH=925,HEIGHT=600,TOP=10,LEFT=30,menubar,toolbar,scrollbars, r esizable');" & "</script>")
something like this would work:
VB Code:
Page.RegisterStartupScript("AssetsAssignedToUser", "<script>" & "window.open('" & "Reports/ReportViewer.aspx','test','WIDTH=925,HEIGHT=600,TOP=10,LEFT=30,menubar,toolbar,scrollbars,resizable');" & "</script>")
points to be noted.
1) Use a http address instead of a file:// address.
Server.MapPath returns a file:// address.
This would have worked for a .html page
2) Use "/" instead of "\"
3) Use relative addressing instead of absolute addressing.