I have page with the following controls:
A textbox
A submit button
A label
A ReportViewer
The page is using telerik ajax and is setup so that when a user clicks on the submit button, the label and the reportviewer is updated.
Now when the user clicks the submit button, the following code is run:
ReportViewer1.Report = new MyReport();
var printScript = String.Format(
"{0}.PrintReport();"
, ReportViewer1.ClientID);
ScriptManager.RegisterStartupScript(
this
,
this
.GetType(),
"ReportPrint"
, printScript,
true
);
The problem where is that the javascript will run before the ajax has rendered the reportviewer and that gives my an error.
So my question is, how can I print the report, using AJAX, when the reportviewer is inside a AJAX update panel?
Regards
Per
12 Answers, 1 is accepted
Generally our suggestion is to enable your print button on ReportViewer.prototype.OnReportLoaded as shown in the following help article. Give it a try and if you still experience any difficulties we will appreciate if you elaborate on the error and open a support thread and send us a sample project that shows the problematic behavior to debug on our end.
Greetings,Peter
the Telerik team
Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.
It will be best if you can open a support ticket and send to us a runnable project so that we can check directly what the problem is and try to suggest a solution for it. Generally speaking you should be able to achieve your goal by using the ReportViewer.prototype.OnReportLoaded function which is called right after the report is shown in the viewer.
All the best,
Chavdar
the Telerik team
Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.
I was aboe to solve my problem using the following code.
Hope this helps someone else :)
var printScript =
""
;
printScript +=
"ReportViewer.OnReportLoadedOld = ReportViewer.OnReportLoaded;"
;
printScript +=
"ReportViewer.prototype.OnReportLoaded = function()"
;
printScript +=
"{"
;
printScript += ReportViewer1.ClientID +
".PrintReport();"
;
printScript +=
"ReportViewer.OnReportLoaded = ReportViewer.OnReportLoadedOld;"
;
printScript +=
"}"
;
ScriptManager.RegisterStartupScript(
this
, GetType(),
"ReportPrint"
, printScript,
true
);
I had the same problem in one of my pages and your solution worked...
But i noticed that for the report it fails the reportPageUrl, basePrintUrl,exportUrl are not having any values. hence when in the printreport it does not print anything...
I have another page where the reportViewer1.PrintReport()... works fine.... when i traded in to the javascript this instance had those values.
Can someone clarify why this happened for me to better understand it.
Thanks
Hello,
I have almost slimier case.
I have page have textbox, button and reportviewer (in hidden div, display:none)
I want to pass parameter to report then print it.
I'm using ReportViewer not HTML5 ReportViewer
Note : report is created direct in root folder under TelerikWebApp3 folder
Could you please share a sample javascript code to pass parameter and print
I need it only from client side not server side.
also I have tried it using HTML5 reportviewer ans success to pass parameter but not able to print as PrintReport is not working with html5 reportviewer !!!
Thanks,
Emad
If you want to print reports at the client without displaying them in a viewer, please check the Direct Client Side Printing - Error forum thread.
I hope this information is helpful.
Regards,
Stef
Telerik
Hello Stef,
Thank you for reply, but unfortunately my issue still not solved.
Can you please share a code how to pass parameter to report viewer from client side then print from client side as well.
Assume parameter name is VISIT_ID
Regards,
Emad
<%=ReportViewer1.ClientID %>.PrintReport();
this working fine for printing, but before I call it I need to pass parameter then refresh report viewer
Thanks,
Emad
The old ASP.NET WebForms ReportViewer can be updated only at the server. In code-behind you can get the viewer's ReportSource and update its Parameters collection. The ReportSource.Parameters collection is mapped by key (Name) to the wrapped report's ReportParameters collection.
Once the viewer is refreshed from code-behind, you can call the viewer's PrintReport Javascript method.
The above scenario is fully supported by the HTML5 Viewer which is a JS/CSS/HTML based widget. Consider the example in How To: Pass Values to Report Parameters. Also the HTML5 Viewer's API allows you to control the viewer client-side.
Regards,
Stef
Telerik
Hi Stef,
thank you you for reply, yes I'm able to pass parameter to new html5 report viewer from client side, but I'm not able to print from outside button from client side code!!
thanks,
Emad
The HTML5 Viewer's API is exposed and you can use the viewers commands to execute print, export, navigation, refresh and other operations.
For example check:
- HTML5 Viewer reportSources(rs);
- HTML5 Viewer: commands - print command;
Regards,
Stef
Telerik