[CLOSED] how direct click event call from (master page) code behind page on clicking menu (which is created dynamically)

  1. #1

    [CLOSED] how direct click event call from (master page) code behind page on clicking menu (which is created dynamically)

    we have a main master page and a nested master page on which we have create dynamic menu but when i am not able to call directs methods Or listeners from code behind...

     public void GetLeftMenu(DataRow[] drMenu)
            {
                for (int i = 0; i < drMenu.Length; i++)
                {
                    //Ext.Net.Button b1 = new Ext.Net.Button();
    
                    //b1.ID = "btn" + i.ToString();
                    //b1.Text = drMenu[i]["MENUNAME"].ToString();
                    //b1.Listeners.Click.Handler = "Ext.net.DirectMethods.LogCompanyInfo();";
    
                    //menupanel.Items.Add(b1);
    
                    Ext.Net.MenuItem menu = new Ext.Net.MenuItem();
                    menu.ID = drMenu[i]["PK_MENUID"].ToString();
                    menu.Text = drMenu[i]["MENUNAME"].ToString();
    
                    menu.DirectEvents.Click.Event += Click_Event;
    
                    MenuPanel1.Menu.Items.Add(menu);
                }
            }
    
            [DirectMethod]
           public static void Click_Event(object sender, DirectEventArgs e)
            {
                X.Msg.Alert("sssss", "ok ---").Show();
            }

    and here id my nested master page code on which i am creating menu dynamically
    
    <asp:Content ID="Content2" ContentPlaceHolderID="pageContent" runat="server">
        <div style="width:20%;float:left;">
            <ext:Panel runat="server"
                ID="pnlSetup"
                Title="Setup"
                Width="250"
                Layout="HBoxLayout"
                MarginSpec="72 0 0 0">
                <Items>
                    <ext:Panel runat="server"
                        ID="menupanel"
                        Title="Meunusss"
                        Border="true"
                        AutoScroll="true"
                        Height="500"
                         Width="250"
                        Layout="FitLayout">
                        <Items>
                            <ext:MenuPanel
                                ID="MenuPanel1"
                                runat="server"
                                Region="West">
                                <Menu ID="Menu1" runat="server">
                                    <Items>
                                    </Items>
                                </Menu>
                            </ext:MenuPanel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Panel>
        </div>
    
        <div  style="width:80%;float:left;margin-top:144px;">
            <asp:ContentPlaceHolder ID="childContentph1" runat="server">
                sdfgsdfgsd
            </asp:ContentPlaceHolder>
        </div>
        <div>
            <asp:ContentPlaceHolder ID="childContentph2" runat="server">
            </asp:ContentPlaceHolder>
        </div>
    </asp:Content>
    Last edited by Daniil; May 05, 2015 at 3:42 PM. Reason: [CLOSED]
  2. #2
    Hi @barnali,

    Please demonstrate where you call the GetLeftMenu method.

    but when i am not able to call directs methods Or listeners from code behind
    More details what is exactly happening would be appreciated.
  3. #3

    issue to get id of dynamic created controls with nested master page if implement !ispostback on page

    create a new master page then create a nested master page and add the below code(create dynamic button) on nested master page , now call nested master page from the aspx web page .

    it create 3 buttons and when click on the button it throw the error button control id not found .

    if we remove (!Page.IsPostBack) from the nested master page then system find the button control and raise event Get_GrantForm properly.

    but for it we need to post back page on every button click and i do not want it , please suggest .

      protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Ext.Net.Button btnApply = new Ext.Net.Button();
                        btnApply.ID = "aaa" + i;
                        btnApply.Text = "Apply";
    
    
                        // create an extra parameter for the button btnApply
                        Ext.Net.Parameter grantType = new Ext.Net.Parameter();
                        grantType.Value = "defsdf";
                        grantType.Name = "grant";
    
                        btnApply.DirectEvents.Click.ExtraParams.Add(grantType);
                        btnApply.DirectEvents.Click.Event += Get_GrantForm;
    
                        // create panels for each grant
                        var grantpnl = new Ext.Net.Panel()
                        {
                            ID = "grantPanel" + "aaaaa" + i,
    
                            Title = "aa" + 1,
                            Collapsible = false,
                            Padding = 15,
                            Height = 145
                        };
                        grantpnl.Buttons.Add(btnApply);
                        containerPanel.Add(grantpnl);
                    }
                }
            }
    
    
    
            protected void Get_GrantForm(object sender, DirectEventArgs e)
            {
                if (e.ExtraParams["grant"] == "URAP")
                {
                    Response.Redirect("GrantForm.aspx");
                }
    
            }

    
    <%@ Master Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="NestedMasterPage1.master.cs" 
        Inherits="ExtMasterPageIssue.NestedMasterPage1" %>
    
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    
         <ext:ResourceManager ID="MasterResource" runat="server"></ext:ResourceManager>
            <ext:Panel id ="containerPanel" runat="server"></ext:Panel>
    
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
          <asp:ContentPlaceHolder ID="nestedcontent" runat="server">
        </asp:ContentPlaceHolder>
    </asp:Content>
    
    
    
    
    
  4. #4
    In brief, a DirectEvent requires a control instance on server. If you don't recreate a control, a DirectEvent is not going to work.

    Here are more details.
    http://forums.ext.net/showthread.php...l=1#post174861

    Please note that X.GetCmp<> is not helpful in your scenario.

    In you scenario you can use a Button's Click Listener + DirectMethod instead of DirectEvent.

Similar Threads

  1. Replies: 1
    Last Post: Jul 01, 2014, 2:37 PM
  2. [CLOSED] can not find direct method in master page .
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 17, 2013, 12:21 AM
  3. Replies: 1
    Last Post: Sep 08, 2013, 5:10 AM
  4. Replies: 1
    Last Post: Jul 15, 2013, 1:35 PM
  5. Replies: 7
    Last Post: Jul 19, 2008, 6:59 AM

Posting Permissions