[CLOSED] The function "addScript" causing the error "Syntax Error"

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #21
    Hello Daniil,

    - I have completed the tests (without an iframe for now) and I have good news.
    - Everything works as expected in all browsers tested(IE11,FF,Chrome).

    Observations:
    1. In debug mode inside VS 2012 the debugger stops code execution only once during the initial loading of the page. Selecting to continue allows the page to load as expected. Subsequent page reloads trigger the same behaviour (break once, select to continue, all goes well). So far, it seems that the theory that the debugger prematurely intervenes and complains about the syntax error before the anchor tag gets a chance to be replaced holds water.
    2. I deployed to production server and no error is raised in the browsers and the page behaves as designed including layouts etc.
    3. I made a little tweak that helped make the initial loading of the page smoother: I do not assign a report path to the report viewer inside its markup tag. I populate the ReportPath property of the Report Viewer in the page's Page_Load event. This causes the report to be loaded a bit later in the page lifecycle when all the scripts had a chance to load properly.

    - I am attaching a sample page for future reference.
    - The sample also demonstrates how to reload a report via a Direct Method passing user defined parameters. (The actual code that passes parameters to the report is outside the scope of this sample).

     
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server"> 
      <title>Reports</title> 
    
    <!--Chrome/FF fix for Report Viewer -->
     <style>
     div#RptViewer1_ctl09
    {
        overflow: visible !important;
    }
     </style>
    
     <script runat="server">
    
        protected void Page_Load(object sender, EventArgs e)
        {
          // check both Ext.Net and ASP.Net for initial loading status in ordr to be on the safe side
          if (!X.IsAjaxRequest && !Page.IsPostBack)
          {        
            //Prepare Report
              this.RptViewer1.ServerReport.ReportPath ="\Reports\test";
       
            //load report
            this.RptViewer1.ServerReport.Refresh();      
          }
        }
    
        [DirectMethod]
        public void Reload_Report(string some_parameter)
        {
    
          // pass parameters to report through ReportViewer.ServerReport.SetParameters method
      
      
          //reload happens in callback handler of Direct Method (client-side)
    
        }
    
    
     </script>
    
     <script type="text/javascript">
    
    function reload_rpt() {
    
      //sample user parameter to pass to report
      var rpt_id = App.txt_rpt_id.value;
    
      App.direct.Reload_Report(rpt_id,  {
          success: function () {
    
            //refresh report using ReportViewers client JS library. This is ReportViewer's JS library, not Ext JS.
            var viewer = $find("RptViewer1");
            if (!viewer.get_isLoading())
              viewer.refreshReport();
           //end of Report Viewer JS library code
    
          },
          eventMask: { showMask: true, msg: "Please wait..." },
          failure: function (errorMsg) { Ext.Msg.alert("Problem", errorMsg); }
      });
    
    
     </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="sm1" runat="server" EnableScriptGlobalization="false" ScriptMode="Debug" />
    
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Default" DisableViewState="false" ScriptMode="Debug"  />
    
          <ext:Viewport ID="vport_main" runat="server" Layout="FitLayout">
            <Items>
              <ext:Panel ID="pnl_main" runat="server" Frame="true" Layout="VBoxLayout" TitleAlign="Center" Icon="Report">
                <LayoutConfig>
                  <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                <Items>
                  <ext:FormPanel ID="pnl_param" runat="server" AutoScroll="true" Hidden="false" Title="params" Collapsible="true" >
                    <Items>
                      <ext:TextField ID="txt_rpt_id" runat="server" AllowBlank="true" FieldLabel="rpt_id" LabelWidth="100" MaxLength="5" EnforceMaxLength="true" MaskRe="[0-9]" MarginSpec="2" Text="1" />                  
                    </Items>
                    <BottomBar>
                      <ext:Toolbar ID="tlb_param" runat="server">
                        <Items>
                          <ext:ToolbarFill runat="server" />                       
                            <ext:Button ID="btn_rpt_reload" runat="server" Text="Execute" >
                                <Listeners>
                                  <Click Fn="reload_rpt" />
                                </Listeners>
                          </ext:Button>
                        </Items>
                      </ext:Toolbar>
                    </BottomBar>
                  </ext:FormPanel>
                  <ext:Panel ID="pnl_rpt" runat="server" AutoScroll="true" Flex="1">
                    <Content>
                      <asp:UpdatePanel runat="server">
    	                  <ContentTemplate>
    				              <rsweb:ReportViewer runat="server" ID="RptViewer1" Font-Names="Verdana" Width="100%" Height="100%" ShowPrintButton="false" ShowFindControls="false" Font-Size="10pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="12pt" >
    					              <ServerReport ReportPath="" ReportServerUrl="http://*.*.*.*/ReportServer" />   
    				              </rsweb:ReportViewer>
    	                  </ContentTemplate>
                      </asp:UpdatePanel>
                    </Content>
                  </ext:Panel>
                </Items>
              </ext:Panel> 
            </Items>
          </ext:Viewport>
    
        </form>
    </body>
    </html>
    I hope that this helps clarify things.

    You can close the thread if you like. I would also like to test the iframe scenario but I am currently under a deadline so that will have to wait.

    Regards,
    AnFil.

    P.S. I can send you the URL of a test production server plus relevant source code files in order to see the user experience client-side and possibly debug the Server Response and also check if any errors are raised in the browsers' JS execution. If you think that such a thing would be helpful please send an e-mail address to my e-mail so i can forward you the relevant information.
    Last edited by AnFil; Sep 25, 2015 at 9:32 PM.

Similar Threads

  1. Replies: 6
    Last Post: May 31, 2013, 3:04 AM
  2. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  3. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  4. Replies: 4
    Last Post: Aug 24, 2011, 11:29 AM
  5. Replies: 8
    Last Post: May 30, 2011, 5:55 PM

Tags for this Thread

Posting Permissions