Create the DirectEvent Click from code behind

  1. #1

    Create the DirectEvent Click from code behind

    I need create the DirectEvent Click from code behind but I can´t get it.

    protected void Page_Load(object sender, EventArgs e)
        {
            
            Ext.Net.Panel panelExample = new Ext.Net.Panel();
            panelExample.ID = "panelExample";
            panelExample.Padding = 15;
            panelExample.ButtonAlign = Alignment.Center;
    
            Ext.Net.Button btnCancel = new Ext.Net.Button();
            btnCancel.ID = "btnCancel";
            btnCancel.Text = "Cancel";
            btnCancel.Icon = Icon.Cancel;
            btnCancel.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(this.btnCancel_Click);
            
            panelExample.Buttons.Add(btnCancel);
    
            panelExample.Render();
            
        }
    
        
        public void btnCancel_Click(object sender, DirectEventArgs e)
        {
    
            MessageBoxConfig win = new MessageBoxConfig();
            win.Title = "Cancel";
            win.Message = "Works fine !!";
            win.Buttons = MessageBox.Button.OK;
            win.Icon = MessageBox.Icon.INFO;
            X.Msg.Show(win);
        }
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test4.aspx.cs" Inherits="test4" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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>Test4</title>    
    </head>
    
    <body>
        
        <form id="fExample" runat="server">
        
           <ext:ResourceManager ID="ResourceManager1" runat="server" />
        </form>
    </body>
    </html>
    The error is: The control with ID 'btnCancel' not found

    I need your help.

    Thanks.
  2. #2
    Hi,

    Replace
    panelExample.Render();
    by
    this.Page.Form.Controls.Add(panelExample);
  3. #3

    Error on DirectEvent

    Hi,

    I am using this code:

    
    newbtnImg.DirectEvents.Click.Event += PanelControlClick_Event;
    
    protected void PanelControlClick_Event(object sender, Ext.Net.DirectEventArgs e)
    {
         //Something
    }

    But it does not work. And when I check for errors I have this one:

    WebResource.axd?d=TF_lcLR8pMPIGw93IZOkrLhV2C2UHsRJ MpkMCpMEJpWzee7cVzKcqKGTLFuYbH-GmdJZ3BAsVGAuW3pBe?:37622 POST http://localhost:57307/Sitio/Monitor...Principal.aspx 500 (Internal Server Error)


    UPDATE: I solved the problem whith a Listener + DirectMethod.

    Thanks.
    Last edited by miguelvelarde; Dec 19, 2014 at 1:08 AM.

Similar Threads

  1. Replies: 5
    Last Post: Mar 19, 2014, 3:35 AM
  2. [CLOSED] Update the DirectEvent Click URL from code behind
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 15, 2011, 10:08 AM
  3. Replies: 1
    Last Post: Jun 09, 2011, 7:04 PM
  4. Replies: 2
    Last Post: Oct 22, 2010, 11:04 AM
  5. [CLOSED] Create an AjaxEvents.click in the code behind
    By HOWARDJ in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 21, 2009, 10:45 AM

Posting Permissions