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

[Solved] how to get the ClientID for RadToolbarToggleButton

1 Answer 94 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 26 Oct 2009, 03:50 PM
Now this would seem to have a straightforward answer for a built in ASP web control...but the Telerik controls gave me some real headache - I tried the following
                string szClientID; 
                //first attempt doesn't work 
                szClientID = RadToolbarToggleButton2.ClientID; 
                //neither this 
                RadToolbarToggleButton tbBut = (RadToolbarToggleButton)MSAToolbar.Items.ToggleButtons[1]; 
                szClientID = tbBut.ClientID; 
                //and again... 
                RadToolbarToggleButton tbBut = (RadToolbarToggleButton)MSAToolbar.FindControl("RadToolbarToggleButton2"); 
                szClientID = tbBut.ClientID; 
As you can see I have a Toolbar called MSAToolbar, which in fact contains all kind of web controls. Built in ASP web controls give an expected ClientID (in a mangled format, ie: "RadToolbarTemplateButton1_ctl00_ddMerchant"), but the ToggleButton.ClientID is the same as the ID on the .aspx markup page, thus cannot reference it properly from javascript. I need it in javascript as I want to set the Toggled property to true/false from client side. I don't want to use the <%=RadToolbarToggleButton.ClientID%> version for a couple of reasons.
is there any way I can accomplish the above written task (getting the ClientID and changing the Toggled property)

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 02 Nov 2009, 11:44 AM
Hi Benjamin,

I'm sorry for the delayed reply.

I guess you're using RadControls for ASP.NET.

You can get the ClientID of the following toolbar:

<radT:RadToolBar ID="MSAToolbar" runat="server">
    <Items>
        <radT:RadToolbarToggleButton ID="RadToolbarToggleButton2" ButtonText="toggle1"
        CommandName="toggle1" />
    </Items>
</radT:RadToolBar>

like this:

string szClientID;
szClientID = MSAToolbar.Items[0].ClientID;

Kind regards,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or