[OPEN] [#937] [3.2.1] Problem with panel LoadContent and SourceFormatting

  1. #1

    [OPEN] [#937] [3.2.1] Problem with panel LoadContent and SourceFormatting

    I'm experiencing an issue trying to load the content of a panel when SourceFormatting is set to true.

    This is a test page to reproduce the problem:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestExtNet.Default" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            resourceManager.ScriptMode = Ext.Net.ScriptMode.Debug;
            resourceManager.SourceFormatting = true;
    
            panelLoader.Loader.Url = "http://ext.net";
            panelLoader.LoadContent();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <ext:ResourceManager ID="resourceManager" runat="server" />
        <title>Test</title>
    </head>
    <body>
        <ext:Viewport runat="server">
            <Items>
                <ext:Panel ID="panelLoader"
                        runat="server">
                    <Loader runat="server" Mode="Frame" DisableCaching="true" AutoLoad="false" />
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    When running this example, Chrome Console reports this error: Uncaught SyntaxError: Unexpected token ILLEGAL

    This is the source of the rendered page. (It looks like there are some extra "\r\n" characters.)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>
        Test
    </title></head>
    <body>
        
        <link type="text/css" rel="stylesheet" href="/extjs/packages/ext_theme_crisp/build/resources/ext-theme-crisp-all-embedded-css/ext.axd?v=19950" id="ext-theme" />
        <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-debug-embedded-css/ext.axd?v=19950" id="extnet-styles" />
        <script type="text/javascript" src="/extjs/ext-all-debug-js/ext.axd?v=19950"></script>
        <script type="text/javascript" src="/extjs/packages/ext_theme_crisp/build/ext-theme-crisp-debug-js/ext.axd?v=19950"></script>
        <script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=19950"></script>
        <script type="text/javascript" src="/extnet/locale/ext-locale-it-debug-js/ext.axd?v=19950"></script>    <script type="text/javascript">
        //<![CDATA[
            Ext.net.ResourceMgr.init({
      id: "resourceManager",
      theme: "crisp",
      locale: "it-IT"
    });Ext.onReady(function(){Ext.create("Ext.container.Viewport",{
      renderTo: Ext.getBody(),
      items: [
        {
      id: "panelLoader",
      loader: {
      autoLoad: false,
      renderer: "frame",
      url: "http://ext.net"
    }
    }
      ]
    });App.panelLoader.load({\r\n  "autoLoad": false,\r\n  "renderer": "frame",\r\n  "url": "http://ext.net"\r\n});});
        //]]>
        </script>
    </body>
    </html>
    If you set SourceFormatting to false, the panel loads correctly.

    I'm using Ext.NET 3.2.1 and .NET Framework v4.
    Last edited by Daniil; Nov 17, 2015 at 12:33 PM. Reason: [OPEN] [#937] [3.2.1]
  2. #2
    Hi @moldeveloper,

    Thank you for the excellent bug report. Created an Issue:
    https://github.com/extnet/Ext.NET/issues/937

    Yes, SourceFormatting is problematic sometimes. Actually, it is just a setting for serialization setting and it breaks in some scenarios like this one. As far as I can see it is not easy fixable.

    So, there are two moments.

    1. We would recommend to avoid using of SourceFormatting="true". Personally, if I need to have a closer look at output JavaScript I copy it and put to:
    http://jsbeautifier.org/

    2. .LoadContent() call in Page_Load is best to avoid as well. The method is rather designed for DirectEvents/DirectMethods. In your case, panelLoader.LoadContent(); might be replaced with panelLoader.Loader.AutoLoad = true;

Similar Threads

  1. Panel.LoadContent() with TexArea inside panel
    By LemonMty in forum 2.x Help
    Replies: 1
    Last Post: Aug 20, 2015, 6:26 PM
  2. [CLOSED] Panel Loader, LoadContent, UpdateContent issue
    By michaeld in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 27, 2013, 2:34 PM
  3. Replies: 2
    Last Post: Apr 02, 2012, 8:03 PM
  4. Replies: 6
    Last Post: Aug 29, 2011, 4:54 PM
  5. [CLOSED] Panel LoadContent
    By drgw74 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 23, 2010, 8:58 AM

Posting Permissions