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

  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]
  2. #2
    Hi @ViDom,

    Please always provide more details how exactly "it doesn't works". In this case, it would be worth to know is a DirectMethod request fired or not?

    I guess not, because I suspect that TabPanel Activate event is not fired.

    I guess you should use Activate event of the TabPanel tabs.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @ViDom,

    Please always provide more details how exactly "it doesn't works". In this case, it would be worth to know is a DirectMethod request fired or not?

    I guess not, because I suspect that TabPanel Activate event is not fired.

    I guess you should use Activate event of the TabPanel tabs.
    Hi @Daniil,
    Yes you have right it's not fired.

    Maybe I need to change Listners type to make it works?

    I do not want to use Events there are always some problem with use them in our enviroment :(
  4. #4
    Quote Originally Posted by ViDom View Post
    Maybe I need to change Listners type to make it works?
    Well, it depends on the requirement.

    Please describe the requirement in details. Then we could suggest something.
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, it depends on the requirement.

    Please describe the requirement in details. Then we could suggest something.
    sorry for delay here I've open new thread:
    http://forums.ext.net/showthread.php...8918#post98918

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