1. #1
    Ext User
    Join Date
    Jul 2008
    Posts
    6
    Vote Rating
    0
    Jaden is on a distinguished road

      0  

    Question problem with aspx treeloader

    problem with aspx treeloader


    I have seen a few examples of the Extjs treeloaders, they are just pure strings like this: [{text:'node1'},{text:'node2',leaf:true},{text:'node3',leaf:true}], and it has .aspx file extension. By the way, this is working well.

    The problem is, when I try to put these strings into the Page_Load method, like this:
    protectedvoid Page_Load(object sender, EventArgs e)
    {
    string json = "[{text:'node1'},{text:'node2', leaf:true},{text:'node3',leaf:true}]";
    Response.Write(json);
    }
    the tree will NOT be rendered. I have seen with Firebug, the POST data has been returned by the server, so strange. According to my point of view, since the JSON is returned with success, there is no reason why the tree does not render. Am I wrong?

    I fully trust this is a simple task, but I dont understand how a simple task getting so complex?

  2. #2
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,761
    Vote Rating
    108
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    1. Post all your relevant code html/js if you want help
    2. Post in [CODE] tags

  3. #3
    Ext User
    Join Date
    Jul 2008
    Posts
    6
    Vote Rating
    0
    Jaden is on a distinguished road

      0  

    Default full HTML and JS code

    full HTML and JS code


    HTMLefault.aspx
    Code:
    <%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="GlobalAdmin._Default" %>
    <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <htmlxmlns="http://www.w3.org/1999/xhtml">
    <headrunat="server">
    <title>Home Page</title>
    <linkrel="stylesheet"type="text/css"href="Ext/resources/css/ext-all.css"/>
    <linkrel="stylesheet"type="text/css"href="css/application.css"/>
    <scripttype="text/javascript"src="Ext/adapter/ext/ext-base.js"></script>
    <scripttype="text/javascript"src="Ext/ext-all-debug.js"></script>
    <scripttype="text/javascript"src="js/application.js"></script>
    </head>
    <body>
    <divid="west1"style="overflow:auto; height:300px;width:250px;border:1pxsolid#c3daf9;"></div>
    
    </body>
    </html>
    
    JS:application.js
    Code:
    /// <reference path="shim.js" />
    /// <reference path="../Ext/adapter/ext/ext-base.js" />
    /// <reference path="../Ext/ext-all-debug.js" />
    Ext.onReady(function(){
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    
    var Tree = Ext.tree;
    //tree1 = the tree under Modules
    var tree1 = new Tree.TreePanel({
    el:'west1',
    useArrows:true,
    autoScroll:true,
    animate:true,
    enableDD:true,
    containerScroll: true, 
    loader: new Tree.TreeLoader({
    dataUrl:'modules.aspx'
    //dataUrl:'data.aspx'
    }),
    root:new Tree.AsyncTreeNode({
    text: 'Ext JS 1',
    draggable:false,
    id:'source1',
    expanded:true
    })
    });
    
    //render the tree
    tree1.render();
    }); //end of onReady
    
    Modules.aspx:
    Code:
    <%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="modules.aspx.cs"Inherits="GlobalAdmin.modules" %>
    <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <htmlxmlns="http://www.w3.org/1999/xhtml">
    <headrunat="server">
    <title>modules</title>
    </head>
    <body>
    <formid="form1"runat="server">
    <div>
    </div>
    </form>
    </body>
    </html>
    
    Code-behind of Modules.aspx:
    Code:
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    namespace GlobalAdmin
    {
    publicpartialclassmodules : System.Web.UI.Page
    {
    protectedvoid Page_Load(object sender, EventArgs e)
    {
    string json = "[{text:'node1'},{text:'node2', leaf:true},{text:'node3',leaf:true}]";
    Response.Write(json);
    }
    }
    }
    

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Of course that's not going to work.

    What output do you think the Tree Loader will get?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Ext User
    Join Date
    Jul 2008
    Posts
    6
    Vote Rating
    0
    Jaden is on a distinguished road

      0  

    Default


    Thank you Evant.
    I removed the followed HTML from the server response by adding Response.End() and it now works.

Thread Participants: 2