Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Friday, March 23, 2012

Open URL in new page from a frame

Hi, i have a problem:
- I need to open a report in a new page, from a report contained in a
iFrame of a aspx page
I tried a javascript window.open command in the "jump to URL" property.
But:
- If i run the report in Explorer, i click and the report is correctly
open in a new page
- If i run the report in the iFrame of the aspx page, i click but the
report is wrongly open in the same page
I tried a lot but i can't see the right way. I really need help.
P.S. Sorry for my bad English LanguageHere is an example of a Jump to URL link I use. This causes Excel to come up
with the data in a separate window:
="javascript:void(window.open('" & Globals!ReportServerUrl &
"?/SomeFolder/SomeReport&ParamName=" & Parameters!ParamName.Value &
"&rs:Format=CSV&rc:Encoding=ASCII','_blank'))"
If you don't want to have it appear in a new window then do this in jump to
URL:
=Globals!ReportServerUrl & "?/SomeFolder/SomeReport&ParamName=" &
Parameters!ParamName.Value & "&rs:Format=CSV&rc:Encoding=ASCII"
This capability was introduced with RS2000 SP1
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Boa" <mugnaboa@.gmail.com> wrote in message
news:1156498995.499936.169520@.h48g2000cwc.googlegroups.com...
> Hi, i have a problem:
> - I need to open a report in a new page, from a report contained in a
> iFrame of a aspx page
> I tried a javascript window.open command in the "jump to URL" property.
> But:
> - If i run the report in Explorer, i click and the report is correctly
> open in a new page
> - If i run the report in the iFrame of the aspx page, i click but the
> report is wrongly open in the same page
> I tried a lot but i can't see the right way. I really need help.
> P.S. Sorry for my bad English Language
>|||I tried a lot of solutions, serious end crazy solutions, but i'm always
in the same situation: i can't open a link in a new page if ny report
is in a iFrame.
[URL=http://img177.imageshack.us/my.php?image=tabellatentativinf4.jpg][IMG]http://img177.imageshack.us/img177/4769/tabellatentativinf4.th.jpg[/IMG][/URL]
In the image u can see my attempts, in the Explorer Column i explain
the result if i run the report directly in the explorer's page, in the
iFrame Column i explain the result if i run the report in my
application. I need to find a "new page" in the iFrame column.
Any idea?|||Bruce ... i need your help!|||Sorry, I don't know why it isn't working. I haven't done what you are trying
to do.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Boa" <mugnaboa@.gmail.com> wrote in message
news:1157640447.600521.206140@.b28g2000cwb.googlegroups.com...
> Bruce ... i need your help!
>

Friday, March 9, 2012

OOpening report in new page without using url.

Sounds simple but here is what I need. I have an aspx webform that asks the user for 19 parameters that my report requires. I need to validate the form and have a button that the user can click and have the report open in a new window. Like I said the report has 19 parameters and we would like to avoid passing the parameters in the url. Here is what I’ve tried:

Using cross-page postback I can pass the parameters captured in the Getparameters webform to the viewreport webpage but it opens on the same window. I can use a regular button or a linkbutton and added “onclick” attributes to run clientside validation before submitting a form. The viewreport webpage has a reportviewer control. I just need to open the report in a new window.

Tried javascript window.open in several places (btnView “onclick”, linkbutton “onclick”, registerclientscriptblock (runs after the form is posted) all giving me the error “object null reference exception” on the report parameters.

Lastly I’m trying to use SOAP and running render method for button on_click but I keep getting the error report path not valid report path needs to be less than 260 characters and must start with slash. Here is the code that I’m using for render method:

Dim rsAsNew RSWebReference.ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

'Render Arguments

Dim resultAsByte =Nothing

Dim reportPathAsString ="/Sales/MonthlySales"

Dim formatAsString ="PDF"

Dim historyIDAsString =Nothing

Dim devInfoAsString = “<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"

'Prepare report Parameters

Dim parameters(0)As RSWebReference.ParameterValue

parameters(0) =New RSWebReference.ParameterValue

parameters(0).Name ="Date"

parameters(0).Value ="09/10/2006"

Dim credentials()As RSWebReference.DataSourceCredentials =Nothing

Dim showhidetoggleAsString =Nothing

Dim encodingAsString =""

Dim mimeTypeAsString =""

Dim warnings()As RSWebReference.Warning =Nothing

Dim reportHistoryParametersAs RSWebReference.ParameterValue() =Nothing

Dim streamIDAsString() =Nothing

rs.Render("MonthlySales","PDF", historyID, devInfo, parameters, credentials, showhidetoggle, encoding, mimeType, reportHistoryParameters, warnings, streamID)

I just want to know if what I want to accomplish is even posible because I’ve been at this for over a week, going Crazy!

I thought maybe the report needed credentials set instead of nothing, but don’t know how to do that. Using VS 2005, SQL 2005

Any help is immensely appreciated!

I've tried a bunch of different things myself and can't seem to get it. It would be nice that after you call rs.Render(), rs would have a property set to the url of what you just ran. There is a method rs.GetReportLink(ReportName as String) but it just returns the url to the report with none of the query string. My guess is you'll be writing a URL Generator and using a RegisterStartUp script to call a javascript:window.open(). Works well for me.|||

I finally figured it out. Seems that I had the incorrect webreference and was sending the wrong parameters, but here is my solution.

I added a web reference to ReportExecution2005 and used the following code:

Response.BufferOutput = True

Response.ClearContent()

Response.ClearHeaders()

Response.AddHeader("content-type", ContentType)

Response.AddHeader("Content-Length", result.Length.ToString)

Response.AddHeader("content-disposition", "attachement;filename='" & FileName & "'")

Response.BinaryWrite(result)

Response.Flush()

Response.Clear()

'End the response

Response.End()

By using content-disposition "attachement" I have the browser ask the user to open or save the report. To have this open in a new window I had to go with the form target=_blank. I did find that different MIME types yield different results. For example using "application/pdf" will open the pdf document in a the recently opened new browser window. Using "application/x-pdf" will open the pdf document in acrobat session leaving a blank page behind. I also tried exporting the report to excel, but the onlyl issue with excel is that it renders the report formated so some columns do not match the cells. I haven't figured out how to render that correctly.