This is a migrated thread and some comments may be shown as answers.

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

7 Answers 120 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arnaud
Top achievements
Rank 1
Arnaud asked on 20 Mar 2012, 04:47 PM

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.

 

7 Answers, 1 is accepted

Sort by
0
Arnaud
Top achievements
Rank 1
answered on 21 Mar 2012, 10:39 AM
Nobody has an idea for resolve or work around this issue :( ?
0
Slav
Telerik team
answered on 23 Mar 2012, 01:23 PM
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.
0
Peter Filipov
Telerik team
answered on 26 Mar 2012, 10:38 AM
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.
0
christian
Top achievements
Rank 1
answered on 03 May 2012, 04:30 PM
Hi, do you have any news about this? im facing the same problem and i need to resolve it asap

thanks!
0
Peter Filipov
Telerik team
answered on 04 May 2012, 09:50 AM
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.
0
Robert Massimi
Top achievements
Rank 1
answered on 16 May 2012, 05:09 AM
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.
0
Peter Filipov
Telerik team
answered on 18 May 2012, 10:48 AM
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.
Tags
General Discussions
Asked by
Arnaud
Top achievements
Rank 1
Answers by
Arnaud
Top achievements
Rank 1
Slav
Telerik team
Peter Filipov
Telerik team
christian
Top achievements
Rank 1
Robert Massimi
Top achievements
Rank 1
Share this question
or