Ext.Net在TabPanel中加载TreePanel的Href

时间:2011-11-08 18:44:06

标签: c# asp.net ext.net

我看过Ext.net的示例网站,其中每个新页面都作为TabPanel控件中的标签/页面添加。

而不是那样,我希望有一个只有一个选项卡/面板的TabPanel,它将显示页面的内容。我复制了我现有的

代码
  • TreePanel定义
  • 从SiteMap填充TreePanel数据的CodeBehind
  • TabPanel定义

在这种情况下,如何在控件“MainPanel”中加载URL?

TreePanel定义

<ext:TreePanel ID="MenuTree" runat="server" Height="300" Width="250" UseArrows="true"
    AutoScroll="true" Animate="true" EnableDD="true" ContainerScroll="true" RootVisible="false">
    <TopBar>
        <ext:Toolbar runat="server">
            <Items>
                <ext:ToolbarTextItem runat="server" Text="<%$Resources:OneResource, Search %>" />
                <ext:ToolbarSpacer />
                <ext:TriggerField ID="TriggerField1" runat="server" EnableKeyEvents="true">
                    <Triggers>
                        <ext:FieldTrigger Icon="Clear" />
                    </Triggers>
                    <Listeners>
                        <KeyUp Fn="filterTree" Buffer="250" />
                        <TriggerClick Handler="clearFilter();" />
                    </Listeners>
                </ext:TriggerField>
                <ext:ToolbarSpacer />
                <ext:LinkButton ID="PreviewLinkButton" runat="server" Text="<%$Resources:OneResource, Preview %>" />
            </Items>
        </ext:Toolbar>
    </TopBar>
</ext:TreePanel>

从SiteMap填充TreePanel数据的CodeBehind

protected void Page_Load(object sender, EventArgs e)
{
    Ext.Net.TreeNode root = this.CreateNode(SiteMap.RootNode);
    root.Draggable = false;
    root.Expanded = true;
    MenuTree.Root.Add(root);
    MenuTree.ExpandAll();
}

/// <summary>
/// Creates nodes from sitemap data
/// </summary>
/// <param name="siteMapNode">Pass the root node of Web.sitemap</param>
/// <returns></returns>
private Ext.Net.TreeNode CreateNode(SiteMapNode siteMapNode)
{
    Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
    treeNode.NodeID = siteMapNode.Key;
    treeNode.Text = siteMapNode.Title;
    treeNode.Qtip = siteMapNode.Description;
    treeNode.Href = siteMapNode.Url;
    treeNode.Icon = this.GetIcon(siteMapNode["menuId"].ToString());
    SiteMapNodeCollection children = siteMapNode.ChildNodes;
    if (children != null && children.Count > 0)
    {
        foreach (SiteMapNode mapNode in siteMapNode.ChildNodes)
        {
            treeNode.Nodes.Add(this.CreateNode(mapNode));
        }
    }
    return treeNode;
}

TabPanel定义

<ext:TabPanel ID="ContentTabPanel" runat="server" Region="Center" Margins="0 4 4 0" EnableTabScroll="true"
    MinTabWidth="85">
    <Items>
        <ext:Panel ID="MainPanel" runat="server" Title="<%$Resources:OneResource, Dashboard %>"
            Icon="Application">
            <AutoLoad Mode="IFrame" Url="~/Admin/Index.aspx" ShowMask="false" />
        </ext:Panel>
    </Items>
    <Plugins>
        <ext:TabCloseMenu runat="server" />
    </Plugins>
</ext:TabPanel>

2 个答案:

答案 0 :(得分:2)

您可以通过两种方式执行此操作:

1)客户方:

MainPanel.autoLoad.url = 'http://www.someurl.com';
MainPanel.reload();

2)通过服务器端的DirectEvent或DirectMethod:

MainPanel.AutoLoad.Url = "http://www.someurl.com";
MainPanel.Reload();

答案 1 :(得分:1)

以下示例演示了它('加载Google'按钮) http://examples.ext.net/#/Panel/BodyMask/Standard_Mask/