ItemCreated not firing

2 posts, 0 answers
  1. DMC Helpdesk
    DMC Helpdesk avatar
    52 posts
    Member since:
    Nov 2007

    Posted 22 Jun 2010 Link to this post

    My ASPX code:
    <telerik:RadToolBar ID="mainToolBar" runat="server"  
                            Style="z-index: 90001" Width="100%" 
                            OnButtonClick="mainToolBar_ButtonClick"  
                            OnClientButtonClicked="OnClientButtonClicked"  
                            onitemcreated="mainToolBar_ItemCreated"
                            <Items> 
                                <telerik:RadToolBarButton ImageUrl="~/images/toolbar/New.gif" AccessKey="N" Text="<u>N</u>ew" 
                                    ToolTip="New" Value="New"
                                </telerik:RadToolBarButton> 
                                <telerik:RadToolBarButton IsSeparator="true" /> 
                                <telerik:RadToolBarButton ImageUrl="~/images/toolbar/print.gif" ToolTip="Print" CommandName="Print" 
                                    Value="Print" /> 
                                <telerik:RadToolBarButton ImageUrl="~/images/toolbar/Excel.png" AccessKey="N" ToolTip="Excel" 
                                    Value="ExportToExcel" PostBack="false"
                                </telerik:RadToolBarButton> 
                                <telerik:RadToolBarButton IsSeparator="true" /> 
                                <telerik:RadToolBarButton ImageUrl="~/images/toolbar/Refresh.gif" ToolTip="Refresh" 
                                    Value="Refresh" PostBack="false"/> 
                                <telerik:RadToolBarButton IsSeparator="true" /> 
                                <telerik:RadToolBarButton ImageUrl="~/images/toolbar/delete.gif" ToolTip="Delete" 
                                    Value="Delete" PostBack="false" /> 
                                    <telerik:RadToolBarButton Value="Search" > 
                                    <ItemTemplate> 
                                     
                                    </ItemTemplate> 
                                    </telerik:RadToolBarButton> 
                            </Items> 
                        </telerik:RadToolBar> 


    my CS code:
     protected void mainToolBar_ItemCreated(object sender, Telerik.Web.UI.RadToolBarEventArgs e) 
        { 
            throw new Exception("ItemCreated fired");  
            
        } 



    Thanks in advance
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Jun 2010 Link to this post

    Hello,

    The ItemCreated event occurs for each new item that is added to the Items collection of the toolbar. In other words, the event fires when adding a dynamically created RadToolBarItem to RadToolBar, or when binding the toolbar to a data source.

    If you wand to access the items in RadToolBar, then you can iterate through the items as shown below.
    C#:
     
            foreach( RadToolBarItem item in mainToolBar.Items ) 
            { 
                 // Your code to modify items 
            } 







    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top