[CLOSED] [#23] Page_Load event in UserControl dynamic load with dynamically control in desktop

  1. #1

    [CLOSED] [#23] Page_Load event in UserControl dynamic load with dynamically control in desktop

    Hi guys,

    I have a Desktop with one module.
    If i click on a specific button, i call a direct method function in Desktop.aspx.
    this function dynamic load an another module( in autorun = true).

    test.ascx use also DevExpress component.

    I don't fire Page_Load from this module.

    The module is show.

    Desktop.aspx
    [DirectMethod]
    public void test()
    {
        _test ucSimpleControl = LoadControl("~test.ascx") as _test;
        DesktopModuleProxy control = Ext.Net.Utilities.ControlUtils.FindControl<Ext.Net.DesktopModuleProxy>(ucSimpleControl);
        DesktopMain.AddModule(control.Module);
    }
    Test.ascx

    <ext:DesktopModuleProxy ID="DesktopModuleProxy1" runat="server">
        <Module ModuleID="tab-win" AutoRun="true">
            <Shortcut Name="test" />
            <Launcher Text="test" />
            <Window>
                <ext:Window ID="WindowsView" runat="server" Title="View" BodyBorder="1"
                    DefaultRenderTo="Form" Border="false" AutoScroll="true" Width="700" Height="350"
                    AutoShow="true" ConstrainHeader="true" Layout="AnchorLayout">
                    <Items>
                        <ext:Panel ID="Panel1" runat="server" AnchorHorizontal="100%" AnchorVertical="100%"   Resizable="true" >
                            <Content>
                                <dx:ASPxGridView ID="Grid" runat="server" Width="100%" DataSourceID="dataSource"
                                    AutoGenerateColumns="False" KeyFieldName="0Id" OnInit="windows_init">
                                    <Columns>
                                    </Columns>
                                    <Settings ShowFilterRow="True" ShowFilterRowMenu="true" ShowVerticalScrollBar="true"
                                        ShowHorizontalScrollBar="true" VerticalScrollBarStyle="Virtual" />
                                </dx:ASPxGridView>
                                <asp:SqlDataSource ID="dataSource" runat="server" EnableCaching="true"></asp:SqlDataSource>
                            </Content>
                        </ext:Panel>
                    </Items>
                </ext:Window>
            </Window>
        </Module>
    </ext:DesktopModuleProxy>
    Test.ascx.cs

    protected void Page_Load(object sender, EventArgs e)
            {
                dataSource.ConnectionString = "ConnectionString";
                dataSource.SelectCommand = "SELECT * FROM table";
                if (!IsPostBack)
                {
                    display();
                }
                else if (Session["Colonne"] != null) _listeColumn = (List<String>)Session["Colonne"];
            }
    Regards
    Last edited by Daniil; Dec 07, 2012 at 3:13 PM. Reason: [CLOSED]
  2. #2
    Hi @Tactem,

    An AddModule method retrieves a DesktopModuleProxy only from a user control. It doesn't register a user control on a page. So, its life cycle is not executed.

    Currently, we can suggest to handle a Window's OnLoad event. You can get controls using a FindControl method.

    We are looking at a possibility to support an Ext.Net.IDynamicUserControl interface for Desktop. An example of using this interface is here:
    https://examples2.ext.net/#/Loaders/...Direct_Method/

    See a DynamicItems.ascx file.
  3. #3
    Test in my DynamicItems.ascx (I'm just the wrong extension by post). I can't use FindControl but i don't now ID of column.

    display method

       Configuration.getInstance().NomTable = "TableTemp";
       List<String> listeColonne = GenerateData.getInstance().getColonne();
       foreach (String colonne in listeColonne)
       {
          if (!colonne.ToLower().Contains("_id") && !colonne.ToLower().Contains("0id"))
          {
             AddColumnDX(colonne, colonne);
          }
       }
    
    private void AddColumnDX(String nomColonne, String type)
            {
                try
                {
                    GridViewDataTextColumn column = new GridViewDataTextColumn();
                    column.Caption = nomColonne;
                    column.Visible = true;
                    column.FieldName = type;
                    Grid.Columns.Add(column);
                }
                catch (Exception err)
                {
                    throw err;
                }
            }
  4. #4
    We don't understand well what exactly a problem. Could you clarify, please?
  5. #5
  6. #6
    Thank you for the details.

    Well, and the problem is the fact that the Page_Load is not executed, right?

    Our suggestion in the post #2 was to use a Window OnLoad event instead of Page_Load. Please clarify did you try it?
  7. #7
    Opened an Issue to track this defect, see

    https://github.com/extnet/Ext.NET/issues/23
  8. #8
    I use tabPanel with directMethod and javascript call now and call aspx instead of ascx


    function addTabs(type, guid)
    {
        try {
            var index = Ext.getCmp('TabPanel').items.length + 1;
            var tab = Ext.getCmp('TabPanel').add(
        {
            id: "Tab" + index,
            title: type,
            closable: true,
            border: false,
            loader:
            {
                url: "../modules/module.aspx?i=" + index + "&g=" + guid,
                renderer: "frame"
            }
        });
            Ext.getCmp('TabPanel').setActiveTab(tab);
        }
        catch (err) {
            App.direct.UnhandledException(err);
        }
    }
  9. #9
    Thank you for the update. It is good.

    We will keep this thread opened to track an implementation of this feature.
    Quote Originally Posted by Daniil View Post
    We are looking at a possibility to support an Ext.Net.IDynamicUserControl interface for Desktop. An example of using this interface is here:
    https://examples2.ext.net/#/Loaders/...Direct_Method/

    See a DynamicItems.ascx file.
  10. #10
    Quote Originally Posted by Daniil View Post
    We will keep this thread opened to track an implementation of this feature.

    Quote Originally Posted by Daniil View Post
    We are looking at a possibility to support an Ext.Net.IDynamicUserControl interface for Desktop. An example of using this interface is here:
    https://examples2.ext.net/#/Loaders/...Direct_Method/

    See a DynamicItems.ascx file.
    Well, a Desktop works directly with a DesktopModuleProxy. It has no access to a user control. So, we can't call its methods in this case.

    So, we are closing a ticket.

    Fortunately, a developer is able to call a user control's method himself after a LoadControl call.

Similar Threads

  1. Replies: 4
    Last Post: Dec 19, 2012, 9:58 AM
  2. [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
  3. dynamic load usercontrol in ext:pannel.
    By PrasadJoshi in forum 1.x Help
    Replies: 5
    Last Post: Jan 17, 2011, 9:54 AM
  4. [CLOSED] [1.0] Load dynamic UserControl with Coolite Controls.
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 22, 2010, 10:27 AM
  5. load usercontrol in desktop control
    By maxdiable in forum 1.x Help
    Replies: 1
    Last Post: Jul 28, 2010, 10:43 PM

Tags for this Thread

Posting Permissions