[CLOSED] How to use DirectMethod inside userControl (ascx) and load another usercontrol dynamically inside tab

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] How to use DirectMethod inside userControl (ascx) and load another usercontrol dynamically inside tab

    Hi,

    sample to reproduce:

    user control
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="controls.Test" %>
    <%@ Import Namespace="controls" %>
    <%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
    
    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            [DirectMethod]
            public void LoadControl(Ext.Net.Panel panel)
            {
                DynamicControl dynamicControl = (DynamicControl) LoadControl("/DynamicControl.ascx");
                dynamicControl.ID = "dynamic_Control_in_" + panel.ID;
                panel.ContentControls.Add(dynamicControl);
                panel.UpdateContent();
            }
    </script>
    <ext:Container runat="server" Layout="Border" ID="container">
        <Items>
            <ext:Panel runat="server" Region="North" Height="40">
                <Items>
                    <ext:Button runat="server" Text="btn north"></ext:Button>
                </Items>
            </ext:Panel>
            <ext:Panel runat="server" Region="Center" Layout="Fit">
                <Items>
                    <ext:TextField runat="server" Text="center"></ext:TextField>
                </Items>
            </ext:Panel>
            <ext:TabPanel runat="server" Region="South" Height="300" Collapsed="true" Collapsible="False" ActiveIndex="0">
                <Items>
                    <ext:Panel runat="server" ID="tab1" Title="Tab1"></ext:Panel>
                    <ext:Panel runat="server" ID="tab2" Title="Tab2"></ext:Panel>
                </Items>
                <Listeners>
                    <Activate Handler="Ext.net.DirectMethods.LoadControl(p)"></Activate>
                </Listeners>
            </ext:TabPanel>
        </Items>
    </ext:Container>
    second user control which should be load in directmethod
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DynamicControl.ascx.cs" Inherits="controls.DynamicControl" %>
    <%@Register assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            txt.Text = this.ID;
        }
    </script>
    
    
    <ext:TextField runat="server" ID="txt"></ext:TextField>
    page:
    <%@ Page Language="C#" %>
    <%@Register  tagPrefix="uc" tagName="Test" src="controls/Test.ascx"%>
    <%@Register assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" %>
    
    <script runat="server">
        
    </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">
        <title>ViDom Example dynamic load uc by directmethod</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
             <ext:Container runat="server" Layout="Fit">
            <Content>
                <uc:Test runat="server"/>
            </Content>
        </ext:Container>
        </form>    
    </body>
    </html>
    I've made this thread to simplify my previous example for faster investigate;) here is related thread:
    http://forums.ext.net/showthread.php...ll=1#post91873

    So why this not working? what am I doing wrong? mb there is something I need to add to use directmethod in usercontrols?

    Regards,
    ViDom
    Last edited by Daniil; Oct 09, 2012 at 10:29 AM. Reason: [CLOSED]

Similar Threads

  1. [CLOSED] Dynamic userControl load with DirectMethod
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Oct 02, 2012, 6:03 PM
  2. Replies: 8
    Last Post: Feb 15, 2012, 9:04 AM
  3. Replies: 13
    Last Post: Jul 29, 2011, 4:24 AM
  4. Help with UserControl inside window
    By dbassett74 in forum 1.x Help
    Replies: 0
    Last Post: May 26, 2009, 4:25 PM
  5. How to have scripts inside UserControl?
    By dbassett74 in forum 1.x Help
    Replies: 3
    Last Post: May 17, 2009, 6:14 PM

Tags for this Thread

Posting Permissions