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

This may be really simple...

2 Answers 57 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Ciaran
Top achievements
Rank 1
Ciaran asked on 09 Jan 2009, 12:50 PM
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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jan 2009, 11:10 AM
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.
0
Peter
Telerik team
answered on 12 Jan 2009, 11:24 AM
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.
Tags
ToolBar
Asked by
Ciaran
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Peter
Telerik team
Share this question
or