How to create Event Click at runtime on MenuItem created at runtime

  1. #1

    How to create Event Click at runtime on MenuItem created at runtime

    Hi have the following error:

    Errore server nell'applicazione '/SM2012'.
    The control with ID 'MnuItm1' not found

    asp.net Designer:
    <ext:Viewport ID="ViewP" runat="server" Layout="BorderLayout">
    <Items>
    <ext:BorderLayout runat ="server">
    <West>
    <ext:Panel ID="pnlLeft" runat="server" Title="Profili" Width="200" MinWidth="100" MaxWidth="200" Split ="true" Margins="5 0 5 5" Collapsible="true" Layout="FitLayout" Region="West">
    <Items>
    <ext:MenuPanel ID="MnuPnlProfili" runat="server" Border="false">
    <Menu ID="MnuProfili" runat="server">
    <Items>
    </Items>
    </Menu>
    </ext:MenuPanel>
    </Items>
    </ext:Panel>
    </West>
    <Center>
    <ext:Panel ID="pnlCenter" runat="server" Title="Profilo Selezionato:" Margins="5 5 5 0" Padding="5" region="Center">
    </ext:Panel>
    </Center>
    </ext:BorderLayout>
    </Items>
    </ext:Viewport>

    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    int idUtente = Convert.ToInt16((Session["USERID"].ToString().Split('|'))[0]);

    //IMPOSTO CIO CHE L'UTENTE LOGGATO PUO FARE IN QUESTA PAGINA(A LIVELLO DI FUNZIONI) IN BASE AI SUOI PRIVILEGI
    DataTable tbPrivilegi = ClsPrivilegi.GetTableFunctionPrivilegi(Enumeratori .TipoFunzionePrivilegi.AllPrivilegi, idUtente);
    tbPrivilegi.Dispose();


    MyConnection myconn = new MyConnection(ClsGlobal.GetConnectionString(ClsGlob al.NameConnectionString));
    DataTable tbProfili = myconn.ExecuteStoredGet("SP_PROFILI_GET");
    foreach (DataRow rgp in tbProfili.Rows)
    {
    Ext.Net.MenuItem itm = new Ext.Net.MenuItem(rgp["NOME"].ToString());
    itm.ID = "MnuItm" + rgp["ID"].ToString();
    itm.Icon = Ext.Net.Icon.BulletBlack;
    itm.DirectEvents.Click.ExtraParams["PID"] = rgp["ID"].ToString();
    itm.DirectEvents.Click.Event += new Ext.Net.ComponentDirectEvent.DirectEventHandler(It mMnuProfilo_Click);
    MnuPnlProfili.Menu.Items.Add(itm);
    }
    MnuPnlProfili.Menu.DataBind();

    myconn = null;

    }
    }

    public void ItmMnuProfilo_Click(object sender, DirectEventArgs e)
    {
    string p = ((Ext.Net.MenuItem)sender).ID;
    }


    Help me!
    Thanks in advance
  2. #2
    Any dynamic control must be recreated, it is ASP.NET requirement (you can find many arcticles about dynamic ASP.NET controls)

Similar Threads

  1. create direct event in runtime to MenuItem
    By elbanna23 in forum 1.x Help
    Replies: 7
    Last Post: Jan 10, 2012, 1:12 PM
  2. create event for gridpanel at runtime
    By kyawthura.mr in forum 1.x Help
    Replies: 4
    Last Post: Aug 10, 2011, 9:20 AM
  3. [CLOSED] [1.0] CommandColumn created runtime does not appear
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 30, 2010, 5:02 PM
  4. Replies: 1
    Last Post: Dec 03, 2009, 10:57 AM
  5. Replies: 1
    Last Post: Aug 13, 2009, 1:17 AM

Posting Permissions