[CLOSED] Add Loader to a Panel Created Dynamically

  1. #1

    [CLOSED] Add Loader to a Panel Created Dynamically

    Hi,

    Well, basically what a want to do is create a panel dynamically and show an html on it. I have managed to do it on a static way, but i need to do it dynamically:

    Here is an example:
    <%@ Page Title="Extranet Jhayber" Language="C#" 
        CodeBehind="Pruebaextnet.aspx.cs" Inherits="Extranet.Pruebaextnet" %>
    
    
    <!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 id="Head1" runat="server">
    
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManagerExt1" runat="server" IDMode="Explicit" />
    
       <ext:Panel runat="server" id="panel1" Layout="ColumnLayout">
            
        </ext:Panel>
    
        <ext:Panel runat="server" id="panel2" Layout="ColumnLayout">
            <items>         
                <ext:Panel  runat="server"  Header="false"  ColumnWidth="0.333" Height="210" Frame="true">
                    <Loader runat="server" Mode="Frame" Url="../docs/360/85600-3-500.html">
                        <LoadMask ShowMask="true" MsgCls="loader" Msg="Cargando"/>
                    </Loader>
                </ext:Panel>
            </items>
        </ext:Panel>
    </body>
    </html>
    and here my cs file:
    public partial class Pruebaextnet : System.Web.UI.Page
        {
    
            protected void Page_Load(object sender, EventArgs e)
            {
                Ext.Net.Panel panelhtml = new Ext.Net.Panel();
                panelhtml.ID = "panelhtml1";
                panelhtml.ColumnWidth = 0.333;
                panelhtml.Height = 210;
                panelhtml.Frame = true;
                panel1.Add(panelhtml);
    
                
                /*Ext.Net.ComponentLoader html = new ComponentLoader();
                html.Mode = LoadMode.Frame;
                html.Url = "../docs/360/85600-3-500.html";
                html.LoadContent();*/
    
    
                /*panelhtml.Loader.Mode = LoadMode.Frame;
                panelhtml.Loader.Url = "";
                panelhtml.LoadContent();*/
    
            }
    As you can see there are 2 panels, panel2 is static and it works fine and its what I want to get in panel1 but in a dynamic way. I've tried to do it with the commented lines, but it has been impossible for me. Any solution?
    Last edited by fabricio.murta; Jul 28, 2018 at 3:44 AM.
  2. #2
    Hello @PascuV!

    Your first comment block is not going to do anything, because it is a dangling loader, not bound to any component. Well, at least won't do anything good.

    Your second block is the way to go. But as you just instantiated the panel, its loader would be null. Then the only missing bit is instantiating componentLoader within panelhtml.Loader (or just binding html therein).

    So you could, among lots of other ways of writing this:

    panelhtml.Loader = new ComponentLoader();
    panelhtml.Loader.Mode = LoadMode.Frame;
    panelhtml.Loader.Url = "62353-test.html";
    or maybe

    panelhtml.Loader = new ComponentLoader()
    {
        Mode = LoadMode.Frame,
        Url = "62355-testc.html"
    };
    In fact, you could golf everything into:

    var panelhtml = new Ext.Net.Panel()
    {
        ID = "panelhtml1",
        ColumnWidth = 0.333,
        Height = 210,
        Frame = true,
        Loader = new ComponentLoader()
        {
            Mode = LoadMode.Frame,
            Url = "62353-test.html"
        }
    };
    
    panel1.Add(panelhtml);
    And then define the dynamic panel in one go.

    I hope this helps!

    EDIT: oh, please notice I dropped the LoadContent() call from the loader, you don't need it during Page_Load at all, because you're feeding the page with the initial configuration of the components, so it will naturally call whatever it needs as the first load of the ComponentLoader's contents.
    Last edited by fabricio.murta; May 04, 2018 at 2:16 PM.
  3. #3
    Thank You Frabicio, its working now!
  4. #4
    Hello @PascuV!

    Thank you very much for your kind feedback. Glad the response was helpful for you!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 1
    Last Post: Feb 06, 2013, 5:39 PM
  2. Replies: 1
    Last Post: Oct 25, 2012, 4:51 PM
  3. Replies: 4
    Last Post: Apr 19, 2012, 8:58 PM
  4. Ext .net Menu Panel dynamically created
    By garag in forum 1.x Help
    Replies: 1
    Last Post: Oct 14, 2011, 9:50 AM
  5. Dynamically created panel content
    By reiben in forum 1.x Help
    Replies: 0
    Last Post: Jun 14, 2011, 7:07 AM

Posting Permissions