This is a migrated thread and some comments may be shown as answers.

ReportViewer in ViewUserControl

2 Answers 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jose Granja
Top achievements
Rank 1
Jose Granja asked on 08 Mar 2011, 06:20 PM
Hi,

I'm using the ReportViewer with MVC2! the structure of the page is:

<Master Page>
<tree node with report list>
<reportViewer>
</Master Page>

the reportViewer is render via a html.RenderPartial method. The problem occurs that the ID of the controls get rendered like this:

intNumber_etc

and then in the code I get something like that:

var 6_ReportViewerControl = new ReportViewer('6_ReportViewerControl','6_ReportViewerControl_ReportToolbar','6_ReportViewerControl_ReportArea_WaitControl','6_ReportViewerControl_ReportArea_ReportCell','6_ReportViewerControl_ReportArea_PreviewFrame','6_ReportViewerControl_ParametersAreaCell', '6_ReportViewerControl_ReportArea_ErrorControl', '6_ReportViewerControl_ReportArea_ErrorLabel', '6_ReportViewerControl_CP', '/EmmaConsultant/Telerik.ReportViewer.axd', 'en-GB', 'en-GB', '5a8d02c91e0547138a03882a8f255652', 'Percent', '100', '', '6_ReportViewerControl_EditorPlaceholder', '6_ReportViewerControl_CalendarFrame', '6_ReportViewerControl_ReportArea_DocumentMapCell', {CurrentPageToolTip:'Current Page',ExportButtonText:'Export',ExportToolTip:'Export',ExportSelectFormatText:'Export to the selected format',FirstPageToolTip:'First page',LabelOf:'of',LastPageToolTip:'Last page',ProcessingReportMessage:'Generating report...',NextPageToolTip:'Next page',ParametersToolTip:'Click to close parameters area|Click to open parameters area',DocumentMapToolTip:'Hide document map|Show document map',PreviousPageToolTip:'Previous page',PrintToolTip:'Print',RefreshToolTip:'Refresh',NavigateBackToolTip:'Navigate back',NavigateForwardToolTip:'Navigate forward',ReportParametersSelectAllText:'<select all>',ReportParametersSelectAValueText:'<select a value>',ReportParametersInvalidValueText:'Invalid value.',ReportParametersNoValueText:'Value required.',ReportParametersNullText:'NULL',ReportParametersPreviewButtonText:'Preview',ReportParametersFalseValueLabel:'False',ReportParametersInputDataError:'Please input data for all parameters.',ReportParametersTrueValueLabel:'True',ZoomToPageWidth:'Page Width',ZoomToWholePage:'Full Page'}, '6_ReportViewerControl_ReportArea_ReportArea', '6_ReportViewerControl_ReportArea_SplitterCell', '6_ReportViewerControl_ReportArea_DocumentMapCell', true, true, 'PDF');

this will fail because you can't create a var in javascript starting with an integer! The generation of the int instead of the ctl is due that the WebForm Control doesn't have a parent Page (as I rendered it thourght html.RenderPartial)

I could put it in the master page and everything will work but I wanted to load each report in Ajax. That's why the reportViewer is in a ViewUserControl and would get called when the user selects a diferent report! Is there any way to prefix the ID ? Or to ban numbers from appearing in the ID? 

A better solution would be that the ReportViewer object would be able to change the report through a Javascript method! That will make things much more easier! 

what is the right approach? I know that in .NET 4 you can fix the ID to be static but telerik framework is counting on that ID beeing generated on a parent basis and I get some errors as well!

any help would be really apreciated!

regards,

jose


2 Answers, 1 is accepted

Sort by
0
Joseph
Top achievements
Rank 1
answered on 25 Mar 2011, 06:17 AM
Hi Jose,

Lucky i ran into this post. I have the same error but stupidly didn't recognize that the Illegal variable name was the cause of it.

Did you get an answer from telerik? Or your own ingenuity?

I am encountering the same problem and cannot find a way around it.

Regards,
James
0
Jose Granja
Top achievements
Rank 1
answered on 25 Mar 2011, 05:38 PM
Hi,

the int number comes because the ViewPage is render throught html.renderpartial and it loses info about the parent control. What I did was to override the id as follows:

public override string ID
        {
            get
            {
                return "ctl00$MainContent";
            }
        }

this show go in the ViewUserControl page. You any string as long as it doesn't start with a number

hope that helps
Tags
General Discussions
Asked by
Jose Granja
Top achievements
Rank 1
Answers by
Joseph
Top achievements
Rank 1
Jose Granja
Top achievements
Rank 1
Share this question
or