[CLOSED] Help: some issue when I simulate your example to open URL as "http://localhost/#id1.1.1#/App/Test/AA.aspx"

  1. #1

    [CLOSED] Help: some issue when I simulate your example to open URL as "http://localhost/#id1.1.1#/App/Test/AA.aspx"

    I simulated your online example.
    Use this example I want to open the page automatically in tabpanel like "http://localhost/#id1.1.1#/App/Test/AA.aspx".
    Please check my code.


    <?xml version="1.0" encoding="utf-8" ?>
    <MENU>
      <SubMenu ParentID="1.1.1">
        <id>1.1.1.1</id>
        <title>AA</title>
        <url>Test/AA.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.1">
        <id>1.1.1.2</id>
        <title>AB</title>
        <url>Test/AB.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.1">
        <id>1.1.1.3</id>
        <title>AC</title>
        <url></url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
    
      <SubMenu ParentID="1.1.1.3">
        <id>1.1.1.3.1</id>
        <title>AC-1</title>
        <url>Test/AC-1.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.2">
        <id>1.1.2.1</id>
        <title>EE</title>
        <url></url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.2.1">
        <id>1.1.2.1.1</id>
        <title>EE-1</title>
        <url>Test/EE-1.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.2.1">
        <id>1.1.2.1.2</id>
        <title>EE-2</title>
        <url>Test/EE-2.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.2.1">
        <id>1.1.2.1.3</id>
        <title>EE-3</title>
        <url>Test/>EE-3.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
    
    
      <SubMenu ParentID="1.1.2">
        <id>1.1.2.2</id>
        <title>EF</title>
        <url></url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.2.2">
        <id>1.1.2.2.1</id>
        <title>EF-1</title>
        <url>Test/EF-1.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    
      <SubMenu ParentID="1.1.2.2">
        <id>1.1.2.2.2</id>
        <title>EF-2</title>
        <url>Test/EF-2.aspx</url>
        <iconcls>icon-buttons</iconcls>
      </SubMenu>
    </MENU>

    TreeMenu.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <TreeMenu>
      <Menu ParentID="0">
        <id>1</id>
        <title>T1</title>
        <url></url>
      </Menu>
    
      <Menu ParentID="1">
        <id>1.1</id>
        <title>T1-1</title>
        <url></url>
      </Menu>
    
      <Menu ParentID="1.1">
        <id>1.1.1</id>
        <title>T1-1-1</title>
        <url>Test/1.aspx</url>
      </Menu>
      <Menu ParentID="1.1">
        <id>1.1.2</id>
        <title>T1-1-2</title>
        <url>Test/2.aspx</url>
      </Menu>
      <Menu ParentID="1.1">
        <id>1.1.3</id>
        <title>T1-1-3</title>
        <url>Test/3.aspx</url>
      </Menu>
    
      <Menu ParentID="1">
        <id>1.2</id>
        <title>T1-2</title>
        <url></url>
      </Menu>
    
    
    
      <Menu ParentID="0">
        <id>2</id>
        <title>T2</title>
        <url></url>
      </Menu>
    
      <Menu ParentID="2">
        <id>2.1</id>
        <title>T2-1</title>
        <url></url>
      </Menu>
    
      <Menu ParentID="2.1">
        <id>2.1.1</id>
        <title>T2-1-1</title>
        <url>Test/3.aspx</url>
      </Menu>
    
      <Menu ParentID="2.1">
        <id>2.1.2</id>
        <title>T2-1-2</title>
        <url>Test/4.aspx</url>
      </Menu>
    
    </TreeMenu>

    Default.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test.Default" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!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">
        <title></title>
        <link rel="stylesheet" type="text/css" href="Resources/CSS/main.css" />
    </head>
    <body>
        <ext:ResourceManager ID="extAjaxScriptManager" runat="server" />
        <ext:Viewport ID="ViewPort1" runat="server">
            <Content>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <North>
                        <ext:StatusBar Cls="custom-statusNorth" ID="statusNorth" runat="server" DefaultText="Framework">
                            <Items>
                            </Items>
                        </ext:StatusBar>
                    </North>
                    <West MinWidth="170" MaxWidth="220" Split="true" Collapsible="true">
                        <ext:Panel ID="WestPanel" runat="server" Title="Menu" Width="170">
                            <Content>
                                <ext:AccordionLayout ID="AccordionMenu" runat="server" Animate="true">
                                </ext:AccordionLayout>
                            </Content>
                        </ext:Panel>
                    </West>
                    <Center>
                        <ext:TabPanel ID="CenterPanel" runat="server" EnableTabScroll="true">
                            <TopBar>
                                <ext:Toolbar ID="tbCenterPanel" runat="server">
                                    <Items>
                                        <ext:Button ID="bRefresh" runat="server" Text="Refresh" Icon="ArrowRefresh">
                                            <Listeners>
                                                <Click Fn="refreshCurrentPanel" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:Button ID="bCopyUrl" runat="server" Text="Copy URL" Icon="PageCopy">
                                            <Listeners>
                                                <Click Fn="copyUrl" />
                                            </Listeners>
                                        </ext:Button>
                                        <ext:ToolbarSeparator />
                                        <ext:Container ID="contSubMenu" runat="server" Layout="ToolbarLayout" />
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Items>
                                <ext:Panel ID="CenterTab1" runat="server" Icon="House" Title="Center" Layout="Fit">
                                    <AutoLoad Mode="IFrame" Url="App/home.aspx" ShowMask="true" />
                                </ext:Panel>
                            </Items>
                            <Listeners>
                                <TabChange Handler="addToken();" />
                            </Listeners>
                            <Plugins>
                                <ext:TabCloseMenu ID="TabCloseMenu1" runat="server" />
                            </Plugins>
                        </ext:TabPanel>
                    </Center>
                    <South>
                        <ext:StatusBar ID="StatusBar1" runat="server" DefaultText="Default status">
                        </ext:StatusBar>
                    </South>
                </ext:BorderLayout>
            </Content>
        </ext:Viewport>
    </body>
    <script type="text/javascript">
    
        var changeSubMenuURL = function (subMenuUrl) {
            var objPanel = Ext.getCmp(CenterPanel.getActiveTab().id);
            objPanel.autoLoad.url = "App/" + subMenuUrl;
            objPanel.reload();
    
            //Reset the URL data for the Panel's hidden URL TextField object
            var hiddenURLField = document.getElementById("ddl" + CenterPanel.getActiveTab().id);
            var hostName = window.location.protocol + "//" + window.location.host;
            var fullLink = hostName + "/#" + CenterPanel.getActiveTab().id + "#/" + objPanel.autoLoad.url;
            hiddenURLField.value = fullLink;
        }
    
        var refreshCurrentPanel = function () {
            Ext.getCmp(CenterPanel.getActiveTab().id).reload(true)
        }
    
        var copyUrl = function () {
            //Get the Panel's hidden URL TextField object
            var hiddenURLField = document.getElementById("ddl" + CenterPanel.getActiveTab().id);
            if (hiddenURLField != null) {
                //Get this object URL value
                Ext.Msg.alert("Full URL Address", hiddenURLField.value);
            }
    
    
        }
    
        var addToken = function () {
            var activeTabId = CenterPanel.getActiveTab().id;
            var dotPosition = activeTabId.indexOf(".");
            if (dotPosition != -1) {
    
    
                //Active current tab page's AccordionMenu
                WestPanel.layout.setActiveItem(parseInt(activeTabId.substring(2, dotPosition)) - 1);
                //Active current tab TreeView point
    
                if (parseInt(activeTabId.substring(2, dotPosition)) == 1) {
                    treePanel1.getNodeById(activeTabId).select()
                }
                else if (parseInt(activeTabId.substring(2, dotPosition)) == 2) {
                    treePanel2.getNodeById(activeTabId).select()
                }
    
            }
    
            //Render the submenu for current tab page
           Ext.net.DirectMethods.CreatSubMenu(activeTabId.substr(2));  //■If run this clause, IE will show the error message, If I cancle this clause, IE can open the page. But could not render the sub menu.   ■
    
    
    
        };
    
        var makeTab = function (id, url, title) {
            var win,
            tab,
            hostName,
            exampleName,
            node,
            tabTip;
    
    
            if (id === "-") {
                id = Ext.id(undefined, "extnet");
                lookup[url] = id;
            }
    
            tabTip = url.replace(/^\//g, "");
            tabTip = tabTip.replace(/\/$/g, "");
            tabTip = tabTip.replace(/\//g, " > ");
            tabTip = tabTip.replace(/_/g, " ");
    
            hostName = window.location.protocol + "//" + window.location.host;
            exampleName = url;
    
            var fullLink = hostName + "/#" + id + "#" + exampleName;
    
            tab = CenterPanel.add(new Ext.Panel({
                id: id,
                tbar: [{
                    //Provide a hidden text file to store current URL
                    id: "ddl" + id,
                    xtype: "textfield",
                    cls: "dlText",
                    width: 364,
                    hidden: true,
                    readOnly: true,
                    value: fullLink
                }
               ],
                title: title,
                tabTip: tabTip,
                hideMode: "offsets",
                autoLoad: {
                    showMask: true,
                    scripts: true,
                    mode: "iframe",
                    url: hostName + "/App" + url
                },
                listeners: {
                    deactivate: {
                        fn: function (el) {
                            if (this.sWin && this.sWin.isVisible()) {
                                this.sWin.hide();
                            }
                        }
                    },
                    destroy: function () {
                        if (this.sWin) {
                            this.sWin.close();
                            this.sWin.destroy();
                        }
                    }
                },
                closable: true
            }));
    
            CenterPanel.setActiveTab(tab);
    
        };
    
        var lookup = {};
    
        var loadExample = function (href, id, title) {
            var tab = CenterTab1.getComponent(id),
            lObj = lookup[href];
            if (id == "-") {
                X.GetHashCode(href, {
                    success: function (result) {
                        loadExample(href, "e" + result, title);
                    }
                });
    
                return;
            }
            lookup[href] = id;
            if (tab) {
                CenterTab1.setActiveTab(tab);
            } else {
                if (Ext.isEmpty(title)) {
                    var m = /(\w+)\/$/g.exec(href);
                    title = m == null ? "[No name]" : m[1];
                }
                title = title.replace(/<span>&nbsp;<\/span>/g, "");
                title = title.replace(/_/g, " ");
                makeTab(id, href, title);
            }
        };
    
        if (window.location.href.indexOf("#") > -1) {
            var directLink = window.location.href.substr(window.location.href.indexOf("#") + 1);
            var id = "-";
            if (directLink.indexOf("#") > -1) {
                id = directLink.substr(0, directLink.indexOf("#"));
                directLink = directLink.substr(directLink.indexOf("#") + 1);
            }
            Ext.onReady(function () {
                if (!Ext.isEmpty(directLink, false)) {
                    loadExample(directLink, id);
                }
            }, window, { delay: 100 });
        }
    
    </script>
    </html>
    Default.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using Ext.Net;
    using Ext.Net.Utilities;
    using System.Web.Hosting;
    
    namespace Test
    {
        public partial class Default : System.Web.UI.Page
        {
    
            #region Fields
            private const string MENU_ID = "id";
            private const string MENU_URL = "url";
            private const string MENU_TITLE = "title";
            private const string MENU_ICONCLS = "iconcls";
            private const string m_szMenuSeparator = "MenuSeparator";
            /*--------------- Variables ----------*/
            DataSet m_dsTreeMenu = new DataSet();
            DataSet m_dsSubMenu = new DataSet();
            public string szUserId = string.Empty;
            #endregion
    
            #region Properties
    
            #endregion
    
            #region Methods
    
            #region Page Initialization and Unload
            protected void Page_Load(object sender, EventArgs e)
            {
                /*----------------Variables Declaration---------------*/
    
                /*----------------Operations---------------*/
    
                if (!X.IsAjaxRequest)
                {
                    GetTreeMenuDataSet();
                    CreatTreeMenu();
                }
                GetSubMenuDataSet();
    
            }
            #endregion
    
            #region Data Validation
    
            #endregion
    
            #region Common Functions
    
    
    
            private void InitTreeLeaf(Ext.Net.TreeNode treeNode, string szParentId)
            {
                /*----------------Variables Declaration---------------*/
                string tmpRootId;
                System.Data.DataView dvMenu;
                Ext.Net.TreeNode tmpTreeNode;
                /*----------------Operations---------------*/
                try
                {
                    tmpRootId = szParentId;
                    dvMenu = new System.Data.DataView();
                    tmpTreeNode = null;
                    dvMenu.Table = m_dsTreeMenu.Tables[0];
                    dvMenu.RowFilter = "parentid = '" + szParentId + "'";
                    foreach (DataRowView drv in dvMenu)
                    {
                        tmpTreeNode = new Ext.Net.TreeNode();
                        tmpTreeNode.NodeID = "id" + drv[MENU_ID].ToString();
                        tmpTreeNode.Text = (string)drv[MENU_TITLE];
                        if (drv[MENU_URL].ToString().Trim() == string.Empty)
                        {
                            tmpTreeNode.Icon = Icon.UserGray;
                        }
                        else
                        {
                            tmpTreeNode.Icon = Icon.Calendar;
                            tmpTreeNode.Listeners.Click.Handler = "loadExample('/" + drv[MENU_URL].ToString() + "','id" + drv[MENU_ID].ToString() + "','" + drv[MENU_TITLE].ToString() + "');";
                        }
                        tmpTreeNode.Expanded = true;
                        treeNode.Nodes.Add(tmpTreeNode);
                        InitTreeLeaf(tmpTreeNode, drv[MENU_ID].ToString());
                    }
                }
                catch
                {
                    throw;
                }
            }
    
    
            private DataSet GetTreeMenuDataSet()
            {
                /*----------------Variables Declaration---------------*/
                string szXmlPath;
                /*----------------Operations---------------*/
                try
                {
                    szXmlPath = "~/TreeMenu.xml";
                    szXmlPath = HostingEnvironment.MapPath(szXmlPath);
                    m_dsTreeMenu.ReadXml(szXmlPath);
    
                    return m_dsTreeMenu;
                }
                catch
                {
                    return null;
                    throw;
                }
    
            }
    
    
            private void CreatTreeMenu()
            {
                /*----------------Variables Declaration---------------*/
                System.Data.DataView dvMenu;
                DataRow[] drMenus;
                /*----------------Operations---------------*/
                try
                {
                    dvMenu = new System.Data.DataView();
                    dvMenu.Table = m_dsTreeMenu.Tables[0];
                    dvMenu.RowFilter = "ParentID='0'";
                    drMenus = m_dsTreeMenu.Tables[0].Select("ParentID='0'");
    
                    foreach (DataRow drMenu in drMenus)
                    {
                        // Create the treepanel
                        Ext.Net.TreePanel treePanel = new TreePanel();
                        treePanel.ID = "treePanel" + drMenu[MENU_ID].ToString();
                        treePanel.Title = drMenu[MENU_TITLE].ToString();
                        treePanel.Icon = Icon.FolderWrench;
                        treePanel.RootVisible = false;
                        treePanel.AutoScroll = true;
                        
                        Ext.Net.TreeNode treeNodeRoot = new Ext.Net.TreeNode("");
                        treeNodeRoot.Expanded = true;
                        treePanel.RootVisible = false;
                        treePanel.Root.Add(treeNodeRoot);
    
                        InitTreeLeaf(treeNodeRoot, drMenu[MENU_ID].ToString());
    
                        // Add TreePanel to Accordion
                        AccordionMenu.Items.Add(treePanel);
                    }
    
      
                }
                catch
                {
                    throw;
                }
            }
    
    
     
            private DataSet GetSubMenuDataSet()
            {
                /*----------------Variables Declaration---------------*/
                string szXmlPath;
                /*----------------Operations---------------*/
                try
                {
                    szXmlPath = "~/SubMenu.xml";
                    szXmlPath = HostingEnvironment.MapPath(szXmlPath);
                    m_dsSubMenu.ReadXml(szXmlPath);
    
                    return m_dsSubMenu;
                }
                catch
                {
                    return null;
                    throw;
                }
    
            }
    
     
            [DirectMethod]
            public void CreatSubMenu(string szTreeId)
            {
                /*----------------Variables Declaration---------------*/
                System.Data.DataView dvMenu;
                DataRow[] drMenus;
                /*----------------Operations---------------*/
                try
                {
                    dvMenu = new System.Data.DataView();
                    dvMenu.Table = m_dsSubMenu.Tables[0];
                    dvMenu.RowFilter = "ParentID='" + szTreeId + "'";
                    drMenus = m_dsSubMenu.Tables[0].Select("ParentID='" + szTreeId + "'");
                    contSubMenu.RemoveAll();
                    foreach (DataRow drMenu in drMenus)
                    {
    
                        Ext.Net.Button button = new Ext.Net.Button();
                        button.ID = "button" + drMenu[MENU_ID].ToString();
                        button.Text = drMenu[MENU_TITLE].ToString();
                        button.IconCls = drMenu[MENU_ICONCLS].ToString();
                        if (drMenu[MENU_URL].ToString().Trim() != string.Empty)
                        {
                            button.Listeners.Click.Handler = "changeSubMenuURL('" + drMenu[MENU_URL].ToString() + "')";
                        }
                        contSubMenu.Add(button);
    
                        System.Data.DataView dvMenuItem;
                        dvMenuItem = new System.Data.DataView();
                        dvMenuItem.Table = m_dsSubMenu.Tables[0];
                        dvMenuItem.RowFilter = "parentid = '" + drMenu[MENU_ID].ToString() + "'";
                        if (dvMenuItem.Count > 0)
                        {
                            InitSubMenuLeaf(button, dvMenuItem);
                        }
                        else
                        {
                            button.Render();
                        }
                    }
    
                }
                catch
                {
                    throw;
                }
            }
    
    
    
            private void InitSubMenuLeaf(Ext.Net.Button button, System.Data.DataView dvMenuItem)
            {
                /*----------------Variables Declaration---------------*/
                Ext.Net.MenuItem menuItem;
                MenuSeparator menuSeparator;
                Ext.Net.Menu menu = new Ext.Net.Menu();
                /*----------------Operations---------------*/
                try
                {
                    foreach (DataRowView drv in dvMenuItem)
                    {
                        if ((string)drv[MENU_TITLE] != m_szMenuSeparator)
                        {
                            menuItem = new Ext.Net.MenuItem();
                            menuItem.ID = "menuItem" + drv[MENU_ID].ToString();
                            menuItem.Text = (string)drv[MENU_TITLE];
                            menuItem.IconCls = drv[MENU_ICONCLS].ToString();
                            if (drv[MENU_URL].ToString().Trim() != string.Empty)
                            {
                                menuItem.Listeners.Click.Handler = "changeSubMenuURL('" + drv[MENU_URL].ToString() + "')";
                            }
                            menu.Items.Add(menuItem);
                        }
                        else
                        {
                            menuSeparator = new MenuSeparator();
                            menu.Items.Add(menuSeparator);
                        }
                    }
                    button.Menu.Add(menu);
                    button.Render();
    
                }
                catch
                {
                    throw;
                }
            }
    
    
    
            [DirectMethod]
            public static int GetHashCode(string s)
            {
                return Math.Abs("/App".ConcatWith(s).ToLower().GetHashCode());
            }
    
    
            #endregion
    
            #region Event Handle
    
            #endregion
    
            #endregion
    
        }
    }
    My environment is IE9.
    Please find Default.aspx Line 119, when I cancle this, IE could open page in tabpanel, but could not render the submenu.
    If run this Line 119, IE9 will show the error message.

    Could you help me ?
    Thanks.
    Last edited by Daniil; Jan 02, 2012 at 8:22 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Is there a JavaScript error or a server Exception? And what exactly? I mean what message can you see?

    How does "activeTabId" look when a error occurs?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,
    Is there a JavaScript error or a server Exception? And what exactly? I mean what message can you see?
    When click treeview point, it can show in the tabpanel,
    Click image for larger version. 

Name:	20111227-01.png 
Views:	106 
Size:	48.2 KB 
ID:	3626

    When directly input the url, it show the error message
    Click image for larger version. 

Name:	20111227-02.png 
Views:	76 
Size:	74.2 KB 
ID:	3627

    But, it is strange that when I cancle "Default.aspx Line 119", and directly input the url, it can show the tabpanel.
  4. #4
    Please answer also this question:
    Quote Originally Posted by Daniil View Post
    How does "activeTabId" look when a error occurs?
    You might need to call a DirectMethod with explicit URL.
  5. #5
    Quote Originally Posted by Daniil View Post
    How does "activeTabId" look when a error occurs? " look when a error occurs?
    I 'am sorry that I debuged "activeTabId" is the default tabPanel Id, is not the dynamically generated tabPanel Id.
    But it is strange, the dynamically tabPanel is generated, I could not get this id.

    Quote Originally Posted by Daniil View Post
    You might need to call a DirectMethod with explicit URL.
    Could you show me a simple sentence?

    Thanks.
  6. #6
    Quote Originally Posted by csssi_coolite View Post
    Could you show me a simple sentence?
    Not sure how it should look in your case.

    I was unable to reproduce the problem using the code you posted.

    I think I need the "/App/Test/AA.aspx" page also to reproduce, right?

    As well what are the exact steps to reproduce?

Similar Threads

  1. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  2. Replies: 5
    Last Post: Sep 14, 2011, 7:35 AM
  3. Replies: 1
    Last Post: Jul 22, 2011, 5:34 PM
  4. Replies: 2
    Last Post: Feb 18, 2011, 10:27 AM
  5. Replies: 4
    Last Post: Nov 24, 2010, 6:06 AM

Posting Permissions