This may be really simple...

3 posts, 0 answers
  1. Ciaran
    Ciaran avatar
    21 posts
    Member since:
    Jun 2008

    Posted 09 Jan 2009 Link to this post

    but its annoying the hell out of me right now

    I simply need the text value of a rad toolbar item

    I have no problem doing what I need in the ButtonClick event but I need the value based on other events on the page

    any ideas?

    Radtoolbar1.item.text doesnt do it for me
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Jan 2009 Link to this post

    Hello Ciaran,

    I tried the following code to get the text of a RadToolBar item and it worked as expected.
    aspx:
    <telerik:RadToolBar ID="RadToolBar1" Width="1000px" runat="server"
            <Items> 
            <telerik:RadToolBarButton Text="Text1"></telerik:RadToolBarButton> 
            <telerik:RadToolBarButton Text="Text2" CssClass="Button"></telerik:RadToolBarButton> 
            <telerik:RadToolBarButton Text="Text3" CssClass="Button"></telerik:RadToolBarButton> 
            <telerik:RadToolBarButton Text="Text4" CssClass="Button"></telerik:RadToolBarButton> 
            </Items> 
            </telerik:RadToolBar> 

    cs:
    protected void Page_Load(object sender, EventArgs e) 
        { 
     
            string strtxt = RadToolBar1.Items[0].Text; 
             
     
        } 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 12 Jan 2009 Link to this post

    Hello,

    Indexing the Items collection is one possible way to do this. Alternatively, you can use the FindItemByValue/Text/Attribute methods. Here is a simple example:

     <telerik:RadToolBar ID="RadToolBar1" runat="server">  
    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            <Items> 
                <telerik:RadToolBarButton runat="server" Value="A" Text="Button 0">  
                </telerik:RadToolBarButton> 
                <telerik:RadToolBarButton runat="server" Value="B" Text="Button 1">  
                </telerik:RadToolBarButton> 
                <telerik:RadToolBarButton runat="server" Value="C" Text="Button 2">  
                </telerik:RadToolBarButton> 
            </Items> 
        </telerik:RadToolBar> 

    C#
    Page_Load(object sender, System.EventArgs e)  
    {  
        Response.Write(RadToolBar1.Items.FindItemByValue("A").Text);  

    VB.NET
     Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            Response.Write(RadToolBar1.Items.FindItemByValue("A").Text)  
        End Sub 




    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top