[1.0] XRender with child controls

  1. #1

    [1.0] XRender with child controls

    Hello.. I found following problem:

    When i add some tabs to my tab panel using XRender like this:


     panel.Render(MyTabPanel, RenderMode.AddTo);

    The panel is dynamicaly created by following code:


    var panel = new Panel(GetTitle(), GetIcon()) { Closable = true }; var formControl = _templateControl.LoadControl("~/Forms/Tariffs/TariffsForm.ascx"); panel.ContentControls.Add(formControl); return panel;

    The content of TariffsForm is following:


    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TariffsForm.ascx.cs" Inherits="VS.WebGUI.Forms.Tariffs.TariffsForm" %> <sc:TariffsDataGrid ID="someId" runat="server" />

    sc:TariffsDataGrid is my server control, and as far as we are here everythings works okay.


    Problem starts when i put some ext control in TariffsDataGrid CreateChildControls method. It this case the tab do not even shows on my tab panel. Also i want to tell you that it works okay if control putted into my server control is asp.net control, the problem is only when i put ext control into my server control.


    Now to proof that it's a XRender problem i want to share following facts with you:


    - When i put only sc:TariffsDataGrid on some page it works okay.
    - When i put only TariffsForm.ascx on some page it works okay.
    - When i open this as a static (not dynamically created) tab it works okay.


    The problem shows only when i'm putting it into panel on my new tab using XRender.


    Please help me to solve this issue, or mark it as a bug and fix it in the final one point O.






  2. #2

    RE: [1.0] XRender with child controls

    Hi,

    Please create test sample (or separate project if required) which demonsrates the problem
  3. #3

    RE: [1.0] XRender with child controls

    Okay.. i will try to prepare some sample for you tomorrow... it will take me some time..Btw. this information could be important... When i'm running it i receive following javascript error:


    Error: ctl00 is not defined
    Source file: http://localhost:59785/WebResource.axd?d=ka5jgJw9EP1jOsGZxxykNiURkcmyzBLm 00HUrXn7tEun_QSGRF7_Mb_KED9jzGgCYL4flPfqs_Lefbyhsy UCgA2&amp;t=634069357537607422
    Wiersz: 234
  4. #4

    RE: [1.0] XRender with child controls

    Okay.. here is my sample project with this bug clearly visible.Read comment in UserControl.ascx file to correctly reproduce error situation.


    Please reply as fast as you can with information if it's really a bug and if you can suggest some workaround for this issue.


    Regards
    Lukasz
  5. #5

    RE: [1.0] XRender with child controls

    Hi,

    I simplified your sample. After I set the .ID of the UserControl the sample started working as expected.

    Example (.aspx)

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="Panel=Ext.Net.Panel" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void AddTab(object sender, EventArgs e)
        {
            var panel = new Panel {
                ID = "Panel1",
                Title = "Tab Title",
                Icon = Icon.DoorOpen,
                Closable = true
            };
    
            var form = this.LoadControl("UserControl.ascx");
            form.ID = "UserControl1";
            
            panel.ContentControls.Add(form);
    
            panel.AddTo(this.TabPanel1);
        }
    </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>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button runat="server" Text="Submit" OnDirectClick="AddTab" />
            
            <ext:TabPanel ID="TabPanel1" runat="server" Height="185" Width="350" />
        </form>
    </body>
    </html>
    Example (.ascx)

    <%@ Control Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:Button ID="Button2" runat="server" Text="Ext.NET Button" />
    
    <asp:Button ID="Button3" runat="server" Text="ASP.NET Button" />
    With XRender, it really does help to explicitly set the .ID of the dynamically generated controls. We're going to be putting more work into the XRender functionality and maybe we can solve (or work-around) this requirement of setting the .ID.

    Hope this helps.

    Geoffrey McGill
    Founder
  6. #6

    RE: [1.0] XRender with child controls

    Hi Geoffrey, thanks for your quick response.

    In the test sample it indeed resolves the issue, but lets place the difficulty level a little bit highier.


    Please add following code to .ascx.cs code:

    protected override void CreateChildControls() { Controls.Add(new GridPanel { AutoHeight = true, AutoWidth = true, ID = "dg1" });  base.CreateChildControls();

    Of course it works okay if i put my user control directly, but if I use xrender grid panel does not show at all.. what about that? any idea?


    Best regards,
    Lukasz

  7. #7

    RE: [1.0] XRender with child controls

    Well, it still works fine, but I don't think your GridPanel configuration will render anything even on a basic Page.

    I modified slightly to render just a Panel.

    Example

    <%@ Control Language="C#" %>
    
    <%@ Import Namespace="Panel=Ext.Net.Panel" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected override void CreateChildControls()
        {
            this.Controls.Add(new Panel
            {
                ID = "Panel1",
                AutoHeight = true,
                Title = "UserControl Panel",
                Html = "This is a Test!",
                Padding = 5
            }); 
            
            base.CreateChildControls();
        }
    </script>
    
    <ext:Button ID="Button2" runat="server" Text="Ext.NET Button" />
    
    <asp:Button ID="Button3" runat="server" Text="ASP.NET Button" />
    Hope this helps.

    Geoffrey McGill
    Founder
  8. #8

    RE: [1.0] XRender with child controls

    The truth is that the problem layed somewhere else then i thought, but thanks for this great example.

    Anyway I found new problem with XRender. I let myselfe to modify one of your examples:


    <%@ Page Language="C#" %>
    <%@ Import Namespace="Ext.Net" %>
    
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            var panel = new Ext.Net.Panel
                            {
                                ID = "Tab",
                                Title = "Tab",
                                Padding = 5,
                                Border = false
                            };
    
    
            panel.Buttons.Add(new Ext.Net.Button("Some button") { Icon = Icon.WrenchOrange });
    
    
            panel.Render(TabPanel1, RenderMode.AddTo);
    
    
            TabPanel1.SetActiveTab("Tab");
        }
    
    
    </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 id="Head1" runat="server">
        <title>Dynamically add a new Panel to a Parent Items Collection - Ext.NET Examples
        </title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <h1>
            Dynamically add a new Panel to a Parent Items Collection</h1>
        <ext:Button ID="Button1" runat="server" Text="Add Item" Icon="Add" OnDirectClick="Button1_Click" />
        <ext:Hidden ID="Hidden1" runat="server" Text="1" />
        <h2>
            Add a Tab Item</h2>
        <ext:TabPanel ID="TabPanel1" runat="server" Height="185" Width="350" EnableTabScroll="true">
            <Items>
                <ext:Panel ID="Panel1" runat="server" Title="Tab 1" Html="Tab 1" Padding="5" />
            </Items>
        </ext:TabPanel>
     
        </form>
    </body>
    </html>



    Now click on add button and see the button placed in the panel. It has no icon, the icon is not shown. Any idea how to fix it?


  9. #9

    RE: [1.0] XRender with child controls

    Call .RegisterIcon on the ResourceManager.

    Example


    this.ResourceManager1.RegisterIcon(Icon.WrenchOrange);

    I'm hoping to automatically handle the registering of the Icons soon, but at the moment, you must manually register.


    Hope this helps.


    Geoffrey McGill
    Founder
  10. #10

    RE: [1.0] XRender with child controls

    Ok.. its some kind of solution, but it will make it much more complicated because i assign icons in commands for buttons and such, not only in my markup.


    Btw. what about the 1.0 final release date? Any news?

Similar Threads

  1. [CLOSED] ForceLayout of child controls
    By RCN in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: May 30, 2012, 3:43 PM
  2. Replies: 4
    Last Post: Jan 31, 2011, 12:39 AM
  3. Replies: 0
    Last Post: Oct 17, 2010, 3:20 PM
  4. Replies: 6
    Last Post: Apr 07, 2010, 4:18 AM

Posting Permissions