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

Page 1 of 3 123 LastLast
  1. #1

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

    Hello,

    I'm migrating my application from the Ext version 2.5.3 to version 3.0.0 and I have the following problem. The surface of the application contains a various control elements of Ext, eg Panels, Trees etc.. Depending on the choice of the user is generated via an Ajax call additional controls over Javascript-Code. The javascript code is passed via the method "addScript" of the ResourceManager to the client. Then the message appears in the IE browser:

    JavaScript critical error in (unknown source location)

    SCRIPT1002: Syntax error

    The added script code has no error. With Fiddler, I noticed that he supplied script code is embedded in the method "Ext.onReady". But it contains additionally the two strings "<#: anchor id =" ExtNetOnReadyBegin">" and <#: anchor id = "ExtNetOnReadyEnd"> " that causes the error.


    abstract from Fiddler

    scriptStartupBlock|ScriptContentWithTags|{"text":" Ext.onReady(function(){\u003c#:anchor id=\"ExtNetOnReadyBegin\" /\u003eExt.net.DirectEvent.showFailure = Ext.emptyFn;Ext.ns(\"Ext.net.DirectMethods\");

    --additional scriptcode

    \u003c#:anchor id=\"ExtNetOnReadyEnd\" /\u003e});","type":"text/javascript"}|
    With the Ext version 2.5.3, this error does not occur. Can somebody help me, to solve this problem.


    Uwe
    Last edited by Daniil; Sep 26, 2015 at 8:41 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Do you use UpdatePanel? Can you provide test case?
  3. #3
    Hello all,

    I have come across the exact same problem with version 3.2.1

    It is on a WebForms page containing Report Viewer / Update Panel / Script Manager embedded within Viewport / Panel / Content.

    I have tried removing the Update Panel but the error still persists.

    sample code

    <%@ 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">
      
    
     
     <style>
     div#RptViewer1_ctl09
    {
        overflow: visible !important;
    }
     </style>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Default" DisableViewState="false" ScriptMode="Debug" />
        <asp:ScriptManager ID="sm1" runat="server" EnableScriptGlobalization="true" />
    
            <ext:Panel ID="pnl_main" runat="server" Frame="true" Layout="VBoxLayout" TitleAlign="Center" Icon="Report">
              <LayoutConfig>
                <ext:VBoxLayoutConfig Align="Center" />
              </LayoutConfig>
              <Items>
                <ext:Panel ID="pnl_param" runat="server" Layout="FitLayout" Height="300" AutoScroll="true" Hidden="true">
                </ext:Panel>
                <ext:Panel ID="pnl_rpt" runat="server" AutoScroll="true" Flex="1">
                  <Content>
    
                  </Content>
    
                </ext:Panel>
              </Items>
            </ext:Panel> 
    
                        <asp:UpdatePanel runat="server">
    	                <ContentTemplate
    				                <rsweb:ReportViewer runat="server" ID="RptViewer1" Font-Names="Verdana" 
    					                Width="100%" Height="100%" ShowPrintButton="false" 
    					                Font-Size="8pt" InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote" 
    					                WaitMessageFont-Names="Verdana" WaitMessageFont-Size="12pt" >
    					                <ServerReport ReportPath="/Reports/test" 
    						                ReportServerUrl="http://127.0.0.1/ReportServer" />
    
                               
    				                </rsweb:ReportViewer>
    	                </ContentTemplate>
                    </asp:UpdatePanel>
    
    
        </form>
    </body>
    </html>
    Generated Error :

    Click image for larger version. 

Name:	SyntaxError_1002.png 
Views:	116 
Size:	21.3 KB 
ID:	24241

    There must be a way to instruct Ext.Net not to insert these anchor tags in the dynamic javascript that is generated.
    (hint: ResourceManager.cs #1387)

    Regards,
    AnFil
    Last edited by AnFil; Sep 21, 2015 at 10:04 PM. Reason: added screenshot
  4. #4
    Hi @AnFil,

    Welcome to the Ext.NET forums!

    Please clarify is the problem only reproducible with a <rsweb:ReportViewer> on the page? If yes, could, please, guide me how to introduce that component into my test project?
  5. #5
    Hello Danil,

    thank you for your prompt reply.

    Please find below a basic web.config to use with sample code above.

    I am using MS VS 2012 Premium Edition. I think that the ReportViewer Server control is installed along with VS2012 so it should reside in the GAC.
    I have also MS SQL Server 2012 installed but i dont thin that this is required.
    The Reportserver is the standard ASP.NET control used for displayin SQL Server Reporting Services Reports.
    You can start a new ASP.NET Report Project from VS and it will automatically configure a simple page with a Report Viewer plus a web.config with the required references.

    <?xml version="1.0" encoding="utf-8"?>
    
    <configuration>
    
      <configSections>
        <section name="extnet" type="Ext.Net.GlobalConfig" requirePermission="false" />
      </configSections>
    
      <system.web>
        <compilation targetFramework="4.5">
          <assemblies>
            <add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
    
      
    
        <!-- This httpHandlers config only required if using IIS6 (or lower) -->
        <!--
        <httpHandlers>
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false" />
        </httpHandlers>
        -->
        <!-- This httpModules config only required if using IIS6 (or lower) -->
        <!--
        <httpModules>
          <add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </httpModules>
        -->
        <pages>
          <controls>
            <add assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" />
          </controls>
          <namespaces>
            <add namespace="Ext.Net" />
      
          </namespaces>
        </pages>
      </system.web>
    
      <extnet theme="Default" licenseKey="*********************" initScriptMode="Linked" />
    
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
    
        <modules>
          <add name="DirectRequestModule" preCondition="managedHandler" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </modules>
    
        <handlers>
          <add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceHandler" />
         <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
        </handlers>
      </system.webServer>
    
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
            <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Ext.Net.Utilities" publicKeyToken="2c34ac34702a3c23" />
            <bindingRedirect oldVersion="0.0.0.0-2.5.0" newVersion="2.5.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Transformer.NET" publicKeyToken="e274d618e7c603a7" />
            <bindingRedirect oldVersion="0.0.0.0-2.1.1" newVersion="2.1.1" />
          </dependentAssembly>
    
        </assemblyBinding>
      </runtime>
    
    </configuration>

    I hope this helps,
    Regards,
    AnFil
  6. #6
    You can start a new ASP.NET Report Project from VS
    Could you, please, clarify where it is the New Project wizard? I don't see. I created a project from the "Reporting" menu item, but it doesn't look to be the case.
  7. #7
    Hello Daniil,

    Please select : File / New web site
    From Project Wizard select : Installed / Templates / Visual C# / ASP.Net Reports Web Site
    A new asp.net website will be created and the Report Wizard will automatially load. We dont need to create a report for our example so please cancel the report wizard (select cancel twice on the pop-up windows).
    You now have a project with a default web page includinga report viewer and a web.config with the proper references.
    You can disregard the local report file created (.rdlc)

    Regards,
    AnFil
  8. #8
    Hello Daniil,

    I have done several more tests and I do not think that you will be able to reproduce the error just with the sample i provided.

    Nevertheless, I think that I have pinpointed the circumstances that can trigger this error.

    I do not wish to post snippets of Ext.Net source code on the forum so I will describe the situation as best as I can.

    The cause of the problem is the code in ResourceManager.cs near line #1387. There is an if/else construct with four options. When the last option is reached (which is what happens when you combine Ext.Net with ReportViewer in a WebForm page) the Resource Manager engulfs the emitted client script (which includes the Direct Method Stubs plus any JS code the the page has) between two tags namely <#: anchor id =" ExtNetOnReadyBegin">" and <#: anchor id = "ExtNetOnReadyEnd"> ". Please look at the screenshot to see the structure of the code that is emmited on the client as dynamic script. As it is obvious, the tags cause a Javascript syntax error and the problem occur.

    I will try to compile an altered version of ext.net.dll that bypasses the tag insertion and test with that to see what happens.

    till later,
    regards,
    AnFil
  9. #9
    The cause of the problem is the code in ResourceManager.cs near line #1387.
    Well, this line is executed with a very simple page like this one below and it works well. Something else is a culprit.

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    I will try to compile an altered version of ext.net.dll that bypasses the tag insertion and test with that to see what happens.
    It is unlikely that it is going to help. On your screenshot Ext.onReady's function is empty. As for <#:anchor> things they should be got rid later in life cycle. That is an internal rendering process in Ext.NET. But something goes wrong and it is not removed. Though, even if <#:anchor> would go away somehow, the function is empty still as I already mentioned. It needs to investigate the reason of that. I would be happy to investigate, but I don't think I can do it without getting it reproducible locally on my side.
  10. #10
    Hello Daniil,

    - thank you for your reply.
    - It is expected that the function appears empty in the screenshot since i removed all Js code and Direct Methods removed to make things simpler. Same thing happens if there is any code between the tags).
    - The important piece of information is that this pair of anchors is a temporary runtime feature that is removed (server-side) later in the dynamic script creation process.
    - I will investigate if the Visual Studio debugger gets mixed up and stops the execution of the dynamic script before the tags have a chance to be removed later.
    - I will also deploy code in mock production server to establish if this problem appears only during debugging but not in deployed code.

    - I will post here any conclusions.

    Thank you for pointing me in the correct direction,
    Regards,
    AnFil
    Last edited by AnFil; Sep 24, 2015 at 9:02 AM.
Page 1 of 3 123 LastLast

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