[CLOSED] [1.0] Help with composite control

  1. #1

    [CLOSED] [1.0] Help with composite control

    Hi,

    I am trying to extend the DropDownField composite control but have run into an issue when adding a menu item.

    When my page is rendered I get an javascript error saying that i.e. 'ctl00_MainContent_NodeBrowser_IndexList_IndexEdit or_ctl22' is undefined

    Breaking into the script goes to the following line, highlighting that eval(result.script); is throwing the exception.

    var task=new Ext.util.DelayedTask(function(o,result,response){if(result.script&&result.script.length>0){(function(o,result,response){eval(result.script);}).call(window,o,result,response);}
    However, when I browse the source html the control is defined:
      {
      id: "ctl00_MainContent_NodeBrowser_IndexList_IndexEditor_russMatrixTest",
      xtype: "netdropdown",
      fieldLabel: "Risk Matrix Test",
      width: 300,
      component: {
      id: "ctl00_MainContent_NodeBrowser_IndexList_IndexEditor_ctl18",
      xtype: "panel",
      items: {
      id: "ctl00_MainContent_NodeBrowser_IndexList_IndexEditor_ctl20",
      xtype: "netmenupanel",
      menu: {
      id: "ctl00_MainContent_NodeBrowser_IndexList_IndexEditor_ctl22",
      xtype: "menu",
      items: {
      id: "ctl00_MainContent_NodeBrowser_IndexList_IndexEditor_menumenuitem",
      text: "russ"
    },
      floating: false
    }
    Now if i extract virtually all the layout code out of our project and into a demo site the error does not occur and the composite DropDownField functions as expected.

    However, if I remove the following line from the CreateChildControl method within the composite control the error does not occur. So I would presume that the menu is the root cause of the issue.
       masterPanel.Items.Add(menuPanel);
    I understand that you will not be able to reproduce this locally but any pointers you could give in what to investigate next would be great.

    The composite control code is as follows:

    public class RiskMatrix : Ext.Net.DropDownField
        {
            protected override void CreateChildControls()
            {
                this.Controls.Clear();
                
                base.CreateChildControls();
                Panel masterPanel = new Panel();
    
                this.Width = 300;
    
                this.Component.Add(masterPanel);
    
                masterPanel.Width = 300;
                masterPanel.Height = 80;
                masterPanel.Layout = "column";
    
                MenuPanel menuPanel = new MenuPanel();
               
                menuPanel.Border = false;
                menuPanel.ColumnWidth = 0.33;
                menuPanel.SaveSelection = false;
    
                masterPanel.Items.Add(menuPanel);
    
                menuPanel.Menu.Items.Add(new MenuItem("russ"));
            }
    
            /// <summary>
            /// 
            /// </summary>
            [Category("0. About")]
            [Description("")]
            public override string XType
            {
                get
                {
                    return "netdropdown";
                }
            }
    
            /// <summary>
            /// 
            /// </summary>
            [Category("0. About")]
            [Description("")]
            public override string InstanceOf
            {
                get
                {
                    return "Ext.net.DropDownField";
                }
            }
    
            
        }
    Last edited by Daniil; Mar 16, 2011 at 10:26 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Try to move
    this.Component.Add(masterPanel);
    to the end of CreateChildControls
  3. #3
    Perfect, I would have never tried that. With composite controls in ASP.Net I have always added the controls to the tree as early as possible!

    Please mark as solved.

    Many Thanks

    Russ

Similar Threads

  1. [CLOSED] Need for a composite control extending Ext.NET
    By Aparna_B in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 10, 2011, 5:38 PM
  2. [CLOSED] Create web server control (composite control)
    By mmmartins in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 13, 2011, 6:18 PM
  3. [CLOSED] Styling Composite Control
    By jthompson in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 01, 2011, 9:18 AM
  4. Replies: 2
    Last Post: Apr 20, 2010, 1:50 PM
  5. COMPOSITE SERVER SIDE CONTROL(gridPanel)
    By marcmvc in forum 1.x Help
    Replies: 1
    Last Post: Apr 15, 2010, 4:45 PM

Posting Permissions