[CLOSED] DirectEvent in WebControl

  1. #1

    [CLOSED] DirectEvent in WebControl

    I have a webcontrol that is created a Ext.Net.Button dynamically in overridden CreateChildControls() of the WebControl. The WebControl is within a page that is using a Masterpage. The Masterpage ID is "Body".

    The button code is as followed:

    SpecialButtons Control:
    Ext.Net.CompositeField buttons = new Ext.Net.CompositeField() { Width = new Unit(600, UnitType.Pixel) };
    
    Ext.Net.Button delete = new Ext.Net.Button() { ID = "DeleteButton", Text = "Delete", Icon = Icon.Delete };
    delete.DirectEvents.Click.Event += this.DeleteClick;
    buttons.Items.Add(delete);
    
    Controls.Add(buttons);
    The DeleteClick is:
    public void DeleteClick(object sender, DirectEventArgs e) {
         string test = null;
    }
    The page calls the control via:
    <custom:SpecialButtons ID="Buttons" runat="server" />
    However, it renders the controls fine. However, whenever I click the button, it throws an error of:
    The control with ID 'Body_DeleteButton' not found
    Can anyone point me in the right direction?
    Last edited by Daniil; Oct 22, 2011 at 6:59 AM. Reason: [CLOSED]
  2. #2
    You must add your control in the Init event of the page or use DirectMethods.
    Ext.Net.Button btnCriarIndice = CriarImageButton(controleID, imagemAdicionar);
                    btnCriarIndice.Listeners.Click.Handler += "#{DirectMethods}.btnCriarIndice_Click();";
                    compositeField.Items.Add(btnCriarIndice);
     [DirectMethod]
            public void btnCriarIndice_Clique()
            {
    
            }
    Look this:
    http://forums.ext.net/showthread.php...CustomControls

    Hope this help.
  3. #3
    Moving the creation of controls to OnInit, seemed to work.

    protected override void OnInit(EventArgs e)
    {
        Ext.Net.CompositeField buttons = new Ext.Net.CompositeField() { Width = new Unit(600, UnitType.Pixel) }; 
    Ext.Net.Button delete = new Ext.Net.Button() { ID = "DeleteButton", Text = "Delete", Icon = Icon.Delete };
    delete.DirectEvents.Click.Event += this.DeleteClick;
    buttons.Items.Add(delete);
     
    Controls.Add(buttons);
    }
    Thanks.

Similar Threads

  1. Replies: 1
    Last Post: Jun 09, 2011, 7:04 PM
  2. [CLOSED] [1.0] WebControl and Ext controls
    By state in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 19, 2010, 6:51 AM
  3. Replies: 3
    Last Post: Oct 07, 2009, 6:32 PM
  4. Replies: 3
    Last Post: May 06, 2009, 3:04 PM
  5. Generic details form in webcontrol
    By plykkegaard in forum 1.x Help
    Replies: 6
    Last Post: Mar 06, 2009, 8:02 AM

Posting Permissions