Event not fire by button when dynamicaly created into a RadOrgChart item

8 posts, 0 answers
  1. Arnaud
    Arnaud avatar
    2 posts
    Member since:
    Mar 2012

    Posted 20 Mar 2012 Link to this post

    Hi,

    I try to generate an OrgChart dynamically, for do that, I need to add actions to the orgChart item (by RadButton).

    In my first POC, I try the programm below.

    <%@ Control language="C#" Inherits="DotNetNuke.Modules.Quanteam.ContractModule.View" AutoEventWireup="false"  Codebehind="View.ascx.cs" %>
    <%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
    <%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
     
    <asp:MultiView ID="multiView" runat="server">
        <asp:View ID="ViewContractDetail" runat="server">
            <telerik:RadOrgChart runat="server" ID="radOrgChart">
                <Nodes>
                    <telerik:OrgChartNode>
                        <ItemTemplate>
                            <div style="background-color: Red; height: 80px; width: 180px;">
                                <telerik:RadButton ID="TestBtnOrgChart" Text="click : 0" runat="server"
                                    OnClick="onClick_Handler"
                                    ValidationGroup="ParamValidationGroup"
                                    ButtonType="LinkButton" BorderStyle="None">
                                    <Icon PrimaryIconUrl="~/images/Add.gif" PrimaryIconLeft="5px" />
                                </telerik:RadButton>
                            </div>
                        </ItemTemplate>
                        <GroupItems>
                            <telerik:OrgChartGroupItem Text="Click for Test" />
                        </GroupItems>
                    </telerik:OrgChartNode>
            </telerik:RadOrgChart>
        </asp:View>
    </asp:MultiView>

     

    private void Page_Load(object sender, System.EventArgs e)
            {
                try
                {
                    System.Web.UI.WebControls.View view = FindControl("ViewContractDetail") as System.Web.UI.WebControls.View;
                    multiView.SetActiveView(view);
     
                    //----------------------------------------------------
                    // RadOrgChart
                    //----------------------------------------------------
     
                    var nodeContract = new OrgChartNode();
                    radOrgChart.Nodes.Add(nodeContract);
     
                    OrgChartGroupItem topContract = new OrgChartGroupItem() { Template = new MyTemplate("btnOrgChart1") };
                    nodeContract.GroupItems.Add(topContract);
     
                    var node = new OrgChartNode();
                    topContract.Node.Nodes.Add(node);
     
                    OrgChartGroupItem missionNode = new OrgChartGroupItem() { Template = new MyTemplate("btnOrgChart2", onClick_Handler) };
                    node.GroupItems.Add(missionNode);
     
                    //----------------------------------------------------
                    // RadButton
                    //----------------------------------------------------
     
                    RadButton radBtn = new RadButton();
                    radBtn.ID = "btn_1";
                    radBtn.Text = string.Format("click : {0}", 0);
                    radBtn.Click += onClick_Handler;
                    view.Controls.Add(radBtn);
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
     
            class MyTemplate : ITemplate
            {
                private string _id;
                private System.EventHandler _onClick;
     
                public MyTemplate(string id)
                {
                    _id = id;
                    _onClick = onClick_Handler;
                }
     
                public MyTemplate(string id, System.EventHandler onClick)
                {
                    _id = id;
                    _onClick = onClick;
                }
     
                public void InstantiateIn(Control container)
                {
                    RadButton radBtn = new RadButton();
                    radBtn.ID = _id;
                    radBtn.Text = string.Format("click {1} : {0}", 0, _id);
                    radBtn.Click += _onClick;
                    container.Controls.Add(radBtn);
                }
     
                protected void onClick_Handler(object sender, System.EventArgs e)
                {
                    RadButton radBtn = sender as RadButton;
                    radBtn.Text = string.Format("click {1} : {0}", Convert.ToInt32(radBtn.Text.Split(':')[1]) + 1, _id);
                }
            }
     
            protected void onClick_Handler(object sender, System.EventArgs e)
            {
                RadButton radBtn = sender as RadButton;
                string[] items = radBtn.Text.Split(':');
     
                radBtn.Text = string.Format("{0} : {1}", items[0], Convert.ToInt32(items[1].Trim()) + 1);
            }

     

    When I try this program, the button created into the OrgChart by API call the Page_Load handler, but not the associated click handler.
    Even if the handler came from the view or from the custom ITemplate class.

    The two buttons of control :
    - generated with the ASX and inside of the OrgChart
    - generated with the API and outside of OrgChart
    works normally.

    Why my two Button generated with API into the OrgChar seems to don't call the Click event.

    For information, I begin on ASP.Net since few week.

    Thanks for your help.

     

  2. Arnaud
    Arnaud avatar
    2 posts
    Member since:
    Mar 2012

    Posted 21 Mar 2012 Link to this post

    Nobody has an idea for resolve or work around this issue :( ?
  3. Slav
    Admin
    Slav avatar
    1359 posts

    Posted 23 Mar 2012 Link to this post

    Hello Arnaud,

    Indeed, the click event of the RadButtons inside the RadOrgChart item is not firing . We need more time to investigate the problem in details. You will be notified as soon as the encountered behavior is inspected.

    All the best,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  4. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 26 Mar 2012 Link to this post

    Hi Arnaud,

    We logged the issue and it is going to be fixed for the upcoming Server Pack 1 (in the middle of April).
    If you bind the control and do not add nodes and items dynamically everything should be working correct with the latest internal build of our controls. If you require we can let you know when the fix is available (in case it is before the mentioned date) so that you can download it and test it.

    As a sign of gratitude for pointing this out I updated your points.

    Regards,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. christian
    christian avatar
    1 posts
    Member since:
    Sep 2011

    Posted 03 May 2012 Link to this post

    Hi, do you have any news about this? im facing the same problem and i need to resolve it asap

    thanks!
  6. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 04 May 2012 Link to this post

    Hello Christian,

    We fixed the issue. Could you please try to test your project with the latest version of our controls - Q1.2012 Service Pack 1. In case you still experience problems, please open a new support thread and send me your project for a local test.

    All the best,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Robert Massimi
    Robert Massimi avatar
    4 posts
    Member since:
    Jan 2008

    Posted 16 May 2012 Link to this post

    I'm using build 2012.1 411 but I'm finding generated buttons do not post back (they post back after a second click though). Is it supposed to be for this build? Is this SP1? I've looked around and I can't see a download for ASP.NET AJAX 2012 SP1 controls.
  8. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 18 May 2012 Link to this post

    Hello Ruairi,

    I am writing to confirm that the 2012 SP1 version is 2012.1.411 and the fix should be available. Could you please open a new support ticket and send us your project for local test? This will helps us resolve the issues faster.

    All the best,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top