|
-
Oct 21st, 2005, 04:37 PM
#1
Thread Starter
Fanatic Member
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. What am I doing wrong?
Thanks!
-
Oct 21st, 2005, 04:53 PM
#2
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>")
-
Oct 21st, 2005, 06:02 PM
#3
Thread Starter
Fanatic Member
mendhak ...
I tried that, but it didn't work ...
-
Oct 22nd, 2005, 11:35 AM
#4
Re: Page.RegisterStartupScript and Javascript question ...
What happens? What do you get? What is the URL of the opened window?
-
Oct 24th, 2005, 12:14 AM
#5
Member
Re: Page.RegisterStartupScript and Javascript question ...
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.
Nikhil Aggarwal

-
Oct 24th, 2005, 10:01 AM
#6
Thread Starter
Fanatic Member
mendhak ...
When I tried your technique, a new window of the same page was opened. I looked at the URL of the new page and it was "http://localhost/sdimv2-1/AssetCenterReports.aspx?Report=UserAssets/Reports/ReportViewer.aspx?" So, it did add the full URL and then appended "/Reports/ReportViewer.aspx" to the original URL of the page.
Nikhil your version worked, but I didn't want to use relative addressing.
I'm trying to pass the fully qualified path to the file that I want to open
The reason I want to use absolute rather than relative addressing is that I am trying to troubleshoot a problem I am having with the reports.
So, if I can't use Server.MapPath to get the absolute address, how do I do it? I suspect that there may have to be some parsing of the document.location.href value .... but that won't be fun because the javascript string in VB.Net would have to be parsed in VB.Net.
Since Server.MapPath only returns the file address, how do I get the http address?
Thanks!
Last edited by OneSource; Oct 24th, 2005 at 10:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|