ItemTemplate not working when buttons are dynamically added server-side

2 posts, 0 answers
  1. Louis
    Louis  avatar
    14 posts
    Member since:
    Mar 2011

    Posted 27 May 2014 Link to this post

    We have been using RadToolbar for a very long time, but until recently we had never used the ItemTemplate functionality.

    While we can display the templates correctly, we are encountering a significant issue when the page is posted back: the templates are not rendered after postback completes.

    After a significant amount of troubleshooting, we have tracked the issue down to dynamically added buttons. We have static templates for most toolbars (defined in a skin), but there are several cases where we need to dynamically add buttons to every toolbar rather than adjusting all of the skins.

    As soon as we insert a new toolbar item after the templated items, the templated items will no longer render after a postback (we have not tried inserting before because that is not something that we need to do.

    We have tried removing and re-adding the dynamic toolbar items and simply ignoring them if they already exist on a postback, but in both cases, the templated items are not rendered.

    I have a sample project that demonstrates the issue, but am not allowed to attach it to this thread.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 May 2014 in reply to Louis Link to this post

    Hi Louis,

    Please have a look into the sample code snippet which works fine at my end. 

    <telerik:RadToolBar ID="RadToolBar1" runat="server">
            <telerik:RadToolBarButton Text="Item1">
            <telerik:RadToolBarButton Text="Item2">

    protected void Page_Load(object sender, EventArgs e)
        Label label = new Label();
        label.ID = "Label1";
        label.Text = "Label1";
        RadToolBarButton toolbarButton1 = RadToolBar1.FindItemByText("Item1") as RadToolBarButton;
        RadButton button = new RadButton();
        button.ID = "RadButton1";
        button.Text = "RadButton";
        RadToolBarButton toolbarButton2 = RadToolBar1.FindItemByText("Item2") as RadToolBarButton;

    Let me know if you have any concern.
Back to Top