Hi,

I have been trying to Create a control that can be rendered using the XRender technique displayed in the examples. The problem I am having is that I cannot seem to be able to create a direct method from a control that is rendered by XRender.

This is the call that creates the Tab Control, which is being called like this from a Grid Control (Also created by XRender): Ext.net.DirectMethods.CreateCodexFormTab(el.store. getAt(rowIndex).data.Id);
        /// <summary>
        /// Creates the Codices Tab using the selected codexId.
        /// </summary>
        [DirectMethod]
        public void CreateCodexFormTab(string codexId)
        {
            SectionInfo section = new SectionInfo(SectionType.CodexForm);

            CodexForm form = section.Component as CodexForm;
            form.CodexId = new Guid(codexId);
            form.DataBind();

            section.Title += " - " + form.CodexName;

            this.CreateTab(section);
        }

        /// <summary>
        /// Creates a new Tab with the selected component.
        /// </summary>
        /// <param name="section">Section Type</param>
        private void CreateTab(SectionInfo section)
        {
            var panel = new Ext.Net.Panel(section.Title, section.Icon);

            panel.ID = "tabPanel" + DateTime.Now.ToString("yyyyMMddHHmmssffff");

            panel.ID = "tabPanel" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
            panel.Closable = true;
            panel.CloseAction = CloseAction.Close;
            panel.Layout = "Fit";

            panel.ContentControls.Add(section.Component);

            panel.Render(this.MainPanel, RenderMode.AddTo);
            this.MainPanel.SetActiveTab(panel);
        }
This works perfectly. The Tab control is displayed and the data loaded without a problem. The problem comes when I click one any of the buttons in the Form inside of the tab control, which is created by XRender.

This is my control's code: (View Part)
    /// <summary>
    /// View Portion of the Codex Form Control.
    /// </summary>
    public partial class CodexForm : FormPanel
    {
        #region Ctor
        /// <summary>
        /// Standard Constructor.
        /// </summary>
        public CodexForm()
        {
            this.Region = Ext.Net.Region.Center;
            this.BaseCls = "x-plain";
            this.Ref = "codexForm";
            this.RenderFormElement = false;

            this.LabelSeparator = ":";
            this.LabelAlign = Ext.Net.LabelAlign.Right;
            this.LabelWidth = 100;
            this.Padding = 5;

            this.Initialize();
        }

        /// <summary>
        /// Factory Constructor.
        /// </summary>
        /// <param name="codexId">Codex Identifier</param>
        public CodexForm(Guid codexId) : this()
        {
            this.CodexId = codexId;
        }
        #endregion

        #region Public Methods
        /// <summary>
        /// Loads the Form.
        /// </summary>
        public override void DataBind()
        {
            this.LoadCodex();
        }
        #endregion

        #region Private Methods
        /// <summary>
        /// Builds the Control's Top Bar.
        /// </summary>
        private void BuildTopBar()
        {
            this.CreateTopBarButtons();
            this.TopBar.Add(new Toolbar {
                Items = {
                    this._addNewBtn,
                    this._editBtn,
                    this._deleteBtn,
                    new ToolbarFill(),
                    this._saveBtn,
                    this._cancelBtn
                }
            });
        }

        /// <summary>
        /// Builds the Form's Items.
        /// </summary>
        private void BuildItems()
        {
            this._idField = new TextField {
                        DataIndex = "Id",
                        FieldLabel = "Identifier",
                        AnchorHorizontal = "90%"
                    };
            this.Items.Add(this._idField);

            this._nameField = new TextField {
                        DataIndex = "Name",
                        FieldLabel = "Name",
                        AnchorHorizontal = "90%"
                    };
            this.Items.Add(this._nameField);

            this._descField = new TextField {
                        DataIndex = "Description",
                        FieldLabel = "Description",
                        AnchorHorizontal = "90%"
                    };
            this.Items.Add(this._descField);

            this._versionField = new TextField {
                        DataIndex = "Version",
                        FieldLabel = "Version",
                        AnchorHorizontal = "90%"
                    };
            this.Items.Add(this._versionField);

            this._contentField = new TextArea {
                                DataIndex = "Content",
                                EnableKeyEvents = true
                            };
            this.Items.Add(new Panel {
                        Title = "Codex Content",
                        AnchorHorizontal = "90%",
                        AnchorVertical = "80%",
                        Layout = "Fit",
                        Collapsible = true,
                        StyleSpec = "margin-left:105px;",
                        Items = {
                            this._contentField
                        },
                        BottomBar = {
                            new StatusBar {
                                CtCls = "word-status",
                                DefaultText = "Ready",
                                Items = {
                                    new ToolbarFill(),
                                    new ToolbarTextItem {
                                        Text = "Size: 0",
                                        CtCls = "x-status-text-panel"
                                    }
                                }
                            }
                        }
                    });
        }

        private void Initialize()
        {
            this.BuildTopBar();
            this.BuildItems();
        }

        /// <summary>
        /// Creates the Top Bar Buttons.
        /// </summary>
        private void CreateTopBarButtons()
        {
            this._addNewBtn = ControlHelper.CreateButton("Add New", Icon.Add, "Ext.net. OnAddNewBtn_Click();");
        }
        #endregion
This is the Controller Part:
    /// <summary>
    /// Controller portion of the Codex Form Control.
    /// </summary>
    public partial class CodexForm
    {
        #region Properties
        /// <summary>
        /// Identifier Field.
        /// </summary>
        private TextField _idField = null;

        /// <summary>
        /// Name Field.
        /// </summary>
        private TextField _nameField = null;

        /// <summary>
        /// Description Field.
        /// </summary>
        private TextField _descField = null;

        /// <summary>
        /// Version Field.
        /// </summary>
        private TextField _versionField = null;

        /// <summary>
        /// Content Field.
        /// </summary>
        private TextArea _contentField = null;

        /// <summary>
        /// Save Button.
        /// </summary>
        private Button _saveBtn = null;

        /// <summary>
        /// Cancel Button.
        /// </summary>
        private Button _cancelBtn = null;

        /// <summary>
        /// Add New Button.
        /// </summary>
        private Button _addNewBtn = null;

        /// <summary>
        /// Edit Button.
        /// </summary>
        private Button _editBtn = null;

        /// <summary>
        /// Delete Button.
        /// </summary>
        private Button _deleteBtn = null;

        /// <summary>
        /// Form State.
        /// </summary>
        private FormState _state = FormState.Browse;

        /// <summary>
        /// Codex Identifier.
        /// </summary>
        private Guid _codexId = Guid.Empty;
       
        /// <summary>
        /// Gets or Sets the Codex Identifier.
        /// </summary>
        /// <value><c>Guid</c></value>
        public Guid CodexId
        {
            get {
                return this._codexId;
            }
            set {
                if(value == Guid.Empty) {
                    throw new ArgumentNullException("Codex Identifier.");
                }
                this._codexId = value;
            }
        }

        /// <summary>
        /// Gets the selected Codex's name.
        /// </summary>
        /// <value><c>string</c></value>
        public string CodexName
        {
            get {
                return this._nameField.Text;
            }
        }
        #endregion

        #region Event Handlers
        /// <summary>
        /// Handles the Event fired when the control is being loaded.
        /// </summary>
        /// <param name="e">Event Arguments</param>
        protected override void OnLoad(EventArgs e)
        {
        }

        /// <summary>
        /// Handles the Event fired when the Add New Button is clicked.
        /// </summary>
        [DirectMethod]
        protected void OnAddNewBtn_Click()
        {
            throw new NotImplementedException();
        }
        #endregion

        #region Private Methods
        /// <summary>
        /// Loads the selected Codex.
        /// </summary>
        private void LoadCodex()
        {
            NodeServiceClient nodeSvc = new NodeServiceClient();
            Codex codex = nodeSvc.GetKnownCodex(this.CodexId);

            this.BindCodex(codex);

            nodeSvc.Close();
        }

        /// <summary>
        /// Binds the selected codex to the form.
        /// </summary>
        /// <param name="codex">Codex.</param>
        private void BindCodex(Codex codex)
        {
            if(codex == null) {
                return;
            }
            this._idField.Text = codex.Id.ToString();
            this._nameField.Text = codex.Name;
            this._descField.Text = codex.Description;
            this._versionField.Text = codex.Version;
            this._contentField.Text = codex.Content;
        }
        #endregion
The button I am trying to click is the Add New Button which should call the DirectMethod: Ext.net. OnAddNewBtn_Click();
        /// <summary>
        /// Creates the Top Bar Buttons.
        /// </summary>
        private void CreateTopBarButtons()
        {
            this._addNewBtn = ControlHelper.CreateButton("Add New", Icon.Add, "Ext.net. OnAddNewBtn_Click();");
        }
Which is implemented as:
        /// <summary>
        /// Handles the Event fired when the Add New Button is clicked.
        /// </summary>
        [DirectMethod]
        protected void OnAddNewBtn_Click()
        {
            throw new NotImplementedException();
        }
For some reason when I click the button I never hit the OnAddNewBnt_Click(), it says it can't find it.

What am I doing wrong ?

Sorry for pasting a lot of code here, but I am pretty sure that the problem is really in the architecture of the control, more than anything else.

Thanks in advance,
Alex.