Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Toolbar > findcotrol in radtoolbar
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered findcotrol in radtoolbar

Feed from this thread
  • marc avatar

    Posted on Sep 19, 2008 (permalink)

    Hi, i cant access the radtoolbarbutton inside the radtoolbar,
    here is my code:

    ASPX:

    <radTB:RadToolbar id="RadToolbar1" runat="server" skin="Outlook" UseFadeEffect="true" >

    <Items>

    <radTB:RadToolbarButton id="btnAdd" DisplayType="TextImage" commandname="Add" ButtonText="Add" buttonimage="../../../../../images/_edit.gif" Visible="False" />

    <radTB:RadToolbarButton id="btnEdit" DisplayType="TextImage" commandname="Edit" buttontext="Edit" buttonimage="../../../../../images/_edit.gif" Visible="False" />

    <radTB:RadToolbarButton id="btnDelete" DisplayType="TextImage" commandname="Delete" buttontext="Delete" buttonimage="../../../../../images/_edit.gif" Visible="False" />

    <radTB:RadToolbarButton id="btnFilter" DisplayType="TextImage" commandname="Filter" buttontext="Filter" buttonimage="../../../../../images/_edit.gif" Visible="False" />

    <radTB:radtoolbarseparator />

    <radTB:RadToolbarButton id="btnClose" DisplayType="TextOnly" commandname="Close" buttontext="Close" Visible="False"/>

    </Items>

    </radTB:RadToolbar>

    VB:

    Dim RadToolbar1 As RadToolbar = Me.FindControl("RadToolbar1")

    Dim btnFilter As RadToolbarButton = RadToolbar1.FindControl("btnFilter")

    btnFilter.ButtonText =

    "UnFilter"


    it doest work, i need to change the caption of that button..

    pls help..

  • Posted on Mar 9, 2009 (permalink)

    Hi Marc,

    Try using the "GetButtonByCommandName" method to get the radToolbar button and then change the ButtonText as show below.

     RadToolbar1.Items.GetButtonByCommandName("Filter").ButtonText  = "Unfilter";

    -Shinu 

     

  • Posted on Mar 25, 2009 (permalink)

    Hi Guys this is an old thread but May be someone else can benefit:

    public void SetToolBarState(string toolbarId, bool state, bool? visible) 
            { 
                Control ctrl = FindControlById(this.Page, toolbarId); 
                if (ctrl != null
                { 
                    if (ctrl is RadToolBar) 
                    { 
                        ((RadToolBar)ctrl).Enabled = state; 
                        ((RadToolBar)ctrl).Visible = visible.GetValueOrDefault(false); 
                    } 
                } 
            } 
             
             
              public Control FindControlById(Control parent, string id) 
            { 
                if (parent.ID == id) 
                { 
                    return parent; 
                } 
     
                foreach (Control c in parent.Controls) 
                { 
                    Control t = FindControlById(c, id); 
                    if (t != null
                    { 
                        return t; 
                    } 
                } 
                return null
            } 


    here are two functoins. One for iterating through the control collection starting at the parent control. so if you would like to find a control on the page just call it with this.Page (ie FindcontrolbyId(this.Page,"Contorlid"))

    The other function is for setting the state of a RadToolbarButton


    BUT the function SetToolbarState only works when there are only RadToolbarButtons on the RadToolbar. So this is where my question comes in. How can I find (set) status of other buttons. Like RadToolbarDropdown. Now I'm using
    RadToolBarItem tbItem = ((RadToolBar)ctrl).FindItemByValue(buttonValue);

    but the RadToolbarDropDown has no value property. So could you supply me, or point me in the direction where I can dynamically set the state of every type of toolbaritem. I ask this because the RadToolBarDropdown has no ID property either. I could use FindByText. But I thought may be you have some better solution for this.

    Thx


  • Posted on Apr 24, 2009 (permalink)

    Hello Stephan,

    Other options to access the RadToolBarDropDown would be to use its index in the RadToolBarItems collection or to find one of the child items and then using the Owner property, get the parent DropDown button. You can find examples of the above mentioned in the following links:
    radtoolbardropdown commandname missing! How do I reference it
    RadToolBarDropDown no value property

    Thanks
    Princy.

  • Posted on Apr 25, 2009 (permalink)

    Hi Princy,

    thanks for the info.

    Regards

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Toolbar > findcotrol in radtoolbar