The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

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

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    - 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).
    Ah, okay. Thank you for clarifying.

    Please try the following. There is Ext.Net\Core\InitScriptFilter.cs file. Please set a breakpoint on the line #77 inside the Transform method.
    protected virtual string Transform()
    {
        return ExtNetTransformer.Transform(HttpContext.Current.Response.ContentEncoding.GetString(this.htmlList.ToArray())); // here
    }
    Please post the result of
    HttpContext.Current.Response.ContentEncoding.GetString(this.htmlList.ToArray())
    and
    ExtNetTransformer.Transform(HttpContext.Current.Response.ContentEncoding.GetString(this.htmlList.ToArray()));
    for the problematic page.

    For example, I tried with this simple page.

    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>


    Before transformation
    (additional manual formatting was applied to improve readability)
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form method="post" action="Work3.aspx" id="ctl01">
            <div class="aspNetHidden">
                <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
                <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
                <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTc1OTU1NjkzNmQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFBWN0bDAzdX2wS05fQK2ohA5LlrJnJ+rasJgnLacyAAhcw2QXcJA=" />
            </div>
    
            <script type="text/javascript">
                //<![CDATA[
                var theForm = document.forms['ctl01'];
                if (!theForm) {
                    theForm = document.ctl01;
                }
                function __doPostBack(eventTarget, eventArgument) {
                    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                        theForm.__EVENTTARGET.value = eventTarget;
                        theForm.__EVENTARGUMENT.value = eventArgument;
                        theForm.submit();
                    }
                }
                //]]>
            </script>
    
            <div class="aspNetHidden">
                <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="3FB72D2A" />
            </div>
    
            <#:item selector="headstart" index="20">
                <script type="text/javascript" src="/extjs/ext-all-debug-js/ext.axd?v=29937"></script>
                <script type="text/javascript" src="/extjs/packages/ext_theme_gray/build/ext-theme-gray-debug-js/ext.axd?v=29937"></script>
                <script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=29937"></script>
            </#:item>
    
            <#:item selector="headend">
                <script type="text/javascript">
                    //<![CDATA[
                    Ext.net.ResourceMgr.init({id:"ctl03",aspForm:"ctl01",theme:"gray",locale:"en-US"});
                    Ext.onReady(function(){
                        <#:anchor id="ExtNetOnReadyBegin" />
                            <#:anchor id="init_script" />
                        <#:anchor id="ExtNetOnReadyEnd" />
                    });
                    //]]>
                </script>
            </#:item>
            
            <#:item selector="headstart" index="10">
                <link type="text/css" rel="stylesheet" href="/extjs/packages/ext_theme_gray/build/resources/ext-theme-gray-all-embedded-css/ext.axd?v=29937" id="ext-theme" />
                <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-debug-embedded-css/ext.axd?v=29937" id="extnet-styles" />
            </#:item>
            
            <ext.net.initscript.warning>
                <script type="text/javascript">Ext.onReady(function(){Ext.Msg.show({title:'Warning',msg:'The <code>web.config</code> file for this project is missing the required DirectRequestModule.<br /><br /><div style="margin-left:48px;"><b>Example</b><br /><br /><code>&lt;system.web><br />&nbsp;&nbsp;&lt;httpModules><br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" /><br />&nbsp;&nbsp;&lt;/httpModules><br />&lt;/system.web></code><br /><br />More information available at "<a href="http://examples.ext.net/?/Getting_Started/Introduction/Overview/">Getting Started</a>".</div><br />',buttons: Ext.Msg.OK,icon: Ext.MessageBox.WARNING});});</script>
            </ext.net.initscript.warning>
            
            <#:item selector="warning" />
            
            <#:item selector="viewstate" />
            
            <#:inputs ref="init_script" index="-100" />
            
            <#:item selector="postback" />
            
            <#:item selector="removeblocks" />
            
            <#:item selector="removeLeadingEmptyLines" />
            
            <#:item selector="removeLeadingEmptyLinesAfterForm" />
        </form>
    </body>
    </html>


    After transformation
    (additional manual formatting was applied to improve readability)
    <!DOCTYPE html>
    <html>
    <head>
        <link type="text/css" rel="stylesheet" href="/extjs/packages/ext_theme_gray/build/resources/ext-theme-gray-all-embedded-css/ext.axd?v=29937" id="ext-theme" />
        <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-debug-embedded-css/ext.axd?v=29937" id="extnet-styles" />
        <script type="text/javascript" src="/extjs/ext-all-debug-js/ext.axd?v=29937"></script>
        <script type="text/javascript" src="/extjs/packages/ext_theme_gray/build/ext-theme-gray-debug-js/ext.axd?v=29937"></script>
        <script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=29937"></script>
    
        <title>Ext.NET v3 Example</title>
    
        <script type="text/javascript">
            //<![CDATA[
            Ext.net.ResourceMgr.init({ id: "ctl03", aspForm: "ctl01", theme: "gray", locale: "en-US" });
            Ext.onReady(function () { });
            //]]>
        </script>
    </head>
    <body>
        <form method="post" action="Work3.aspx" id="ctl01">
            <div class="aspNetHidden">
            </div>
    
            <div class="aspNetHidden">
                <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="3FB72D2A" />
            </div>
        </form>
    </body>
    </html>
    Daniil Veriga
    Developer & Support Expert
  2. #12
    ... 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.
    Could you, please, clarify why you don't think that I will be able to reproduce it?:) Following your steps to create a Reports web site it looks like I've got it reproducible. I am investigating. The previous post might be disregarded.
    Daniil Veriga
    Developer & Support Expert
  3. #13
    Hello Daniil,

    - I made that quotation because I observed that the compiler intervened after the Report Viewer had executed a report. Since in my posted example there was no actual report for the Report Viewer to load and process I assumed (apparently incorrectly) that that the stoppage will not occur.

    - I am not yet done investigating the issue further, but my current estimate is that we are not dealing with a bug in Ext.Net, but with a specific situation where the Visual Studio JS debugger prematurely intervenes and stops code execution due to this temporary tag being inserted.

    - I have discovered that if i continue code execution in VS things proceed as normal and the tag is actually removed at a later time exactly as you described.

    - I will try tonight to deploy the code in production server with actual SQL Server Reports and I am confident that there will be no problem in report execution and no JS errors will occur in clients browser.


    Regards,
    AnFil

    P.S.: Since I am new here, I would like to sincerely congratulate the whole Ext.Net team. You are doing excellent work and you make programmer's daily lives easier. I would never consider utilising Ext JS by itself. Ext.Net is the true productivity multiplier and it is an amazing experience to discover. For that I am grateful.
    Last edited by AnFil; Sep 25, 2015 at 8:14 AM.
  4. #14
    Thank you very much for the kind words! It motivates!
    - I will try tonight to deploy the code in production server with actual SQL Server Reports and I am confident that there will be no problem in report execution and no JS errors will occur in clients browser.
    I am afraid the error will be reproducible still.

    I am testing with this page of a basic Reports web site that I created following your steps.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register 
        Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" 
        Namespace="Microsoft.Reporting.WebForms" 
        TagPrefix="rsweb" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            X.Js.AddScript("alert('Page_Load');");
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" DisableViewState="false" />
    
            <ext:Button runat="server" Text="Ext.NET Button" Handler="alert('Hello!');" />
    
            <asp:ScriptManager runat="server" />
    
            <rsweb:ReportViewer runat="server">
                <LocalReport ReportPath="report1.rdlc" />
            </rsweb:ReportViewer>
        </form>
    </body>
    </html>
    So far, I have found out the following.

    1. The initial page load happens well.
    2. Then <rsweb:ReportViewer> initiates a Microsoft AJAX request to load its content.
    3. Something wrong is happening during that request - the ResourceManager is being re-rendered. It should not happen. It is like <rsweb:ReportViewer> somehow wraps a ResourceManager into <asp:UpdatePanel> (not supported, actually) or does something else. So far, I could not determine what happens exactly.
    4. I could reproduce the similar (same?) issue without <rsweb:ReportViewer> in a regular ASP.NET project. If wrap a ResourceManager into an UpdatePanel, the same issue appears after a Microsoft AJAX request. Well, that is not supported scenario - having a ResourceManager inside an UpdatePanel, but I am just posting my findings hoping that it might help narrow the problem down.

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            X.Js.AddScript("alert('Page_Load');");
        }
    
        protected void Button_Click(object sender, EventArgs e)
        {
        }
    </script>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <asp:ScriptManager runat="server" />
    
            <asp:UpdatePanel runat="server">
                <ContentTemplate>
                    <ext:ResourceManager runat="server" />
    
                    <asp:Button runat="server" Text="ASP.NET Button" OnClick="Button_Click" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>
    5. I am still investigating.
    Daniil Veriga
    Developer & Support Expert
  5. #15
    Hello Daniil,

    - I think that during one of several tests I had the Update Panel removed and I was still getting the same behavior.
    - I will also test if removing the update panel causes problems with the report viewer (which is also using ajax).

    - It is a little bit messy to be honest. We have the Ext.Net Resource Manager producing dynamic JS in the App. namespace and then we have ASP.NET Script Manager doing the same in the Sys. namespace in order to load Report Viewer's scripts and then we also wrap the Report Viewer inside an Update Panel that also does also its own stuff.

    - I would like to note that in the page markup only the Report Viewer is "wrapped" inside the Update Panel. The rest of the page (including all Ext.Net controls and Resource manager) are outside the Update Panel. If course this doesn't necessarily means that during dynamic script rendering the whole thing does not become intertwined.

    Regards,
    AnFil.

    P.S.: Glad to hear it helps. It is also the thruth. Keep up the good work.
    Last edited by AnFil; Sep 25, 2015 at 10:52 AM.
  6. #16
    So far, I tend to think that a ReportViewer somehow forces re-rendering of ResourceManager. I cannot prove it since I don't know what happens exactly. I would be happy to look under hood of ReportViewer, but I could not find its sources.

    Intuitively I feel that it is a problematic scenario to use Ext.NET and ReportViewer on the same page. Well, it is already problematic. But I mean that even if solve this problem, others might appear.

    Would it be appropriate for you to move a ReportViewer into an individual page and load it as a child iframe on a page with Ext.NET as a parent?
    <ext:Container runat="server" Height="300" Width="300">
        <Loader runat="server" Mode="Frame" Url="Report.aspx" />
    </ext:Container>
    Daniil Veriga
    Developer & Support Expert
  7. #17
    Hello Daniil,

    - That is a very interesting suggestion. I assume that it will be loaded as an iframe.
    (Weren't there some memory issues back in Ext JS 4.x with iframes?)

    - I will thoroughly test all scenarios (UpdatePanel+ReportViewer+ExtNetPanels, ReportViewer+ExtNetPanels, ReportViewerViaLoader) and i will post the results here when completed.

    Regards,
    AnFil
  8. #18
    - That is a very interesting suggestion. I assume that it will be loaded as an iframe.
    (Weren't there some memory issues back in Ext JS 4.x with iframes?)
    My last investigation made me think that it is rather a problem with browsers and big JavaScript files.
    http://forums.ext.net/showthread.php...l=1#post213872

    So, your iframe is not going to hold Ext.NET and its JavaScript files and it should be okay.
    Daniil Veriga
    Developer & Support Expert
  9. #19
    Hello Daniil,

    - just a quick trivial question.
    - Can a container like the one you suggest participate in the Layout of a parent panel for instance (in italics):

    
    <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:Container ID="pnl_rpt" runat="server" AutoScroll="true" Flex="1">
                    <Loader runat="server" Mode="Frame" Url="Report.aspx" />
                </ext:Container>
              </Items>
            </ext:Panel>
    - The reason for that is that I want the Report Viewer to resize accordingly (Viewport plus top panel collapsing ).



    Regards,
    AnFil
  10. #20
    Yes, the Container itself will participate in the layout. Also the iframe element will be stretched to take all the available size in the Container. But how the report element is going to be sized inside the iframe element is not under control of Ext.NET layout.
    Daniil Veriga
    Developer & Support Expert
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

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

Tags for this Thread

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.