select

ToolBar / Client-side API

Rate this demo: Feedback
Run example in: C# VB.NET Change Skin:
Vista
  • BlackBlack
  • DefaultDefault
  • ForestForest
  • HayHay
  • Office2007Office2007
  • OutlookOutlook
  • SimpleSimple
  • SitefinitySitefinity
  • SunsetSunset
  • TelerikTelerik
  • VistaVista
  • Web20Web20
  • WebBlueWebBlue
  • Windows7Windows7


Example Configuration

Example Source Code & Description

Instructions
Open in new window
  • RadToolBar provides a flexible client-side API - you can easily interact with the toolbar in the browser using the toolbar client-side object.

    1. Getting the RadToolBar client-side object: RadToolBar creates a client-side object with the ClientID of the toolbar. You can obtain the reference using the following javascript code:
      var toolBar = $find("<%=RadToolBar1.ClientID%>");
      
    2. Once you get the client-side object of RadToolBar, you can use the findItemByText method to get the instance of a particular item. Example:
      var toolBar = $find("<%= RadToolBar1.ClientID %>");
      var text = $get("<%= TextBox1.ClientID %>").value;
      var item = toolBar.findItemByText(text);
      		
    3. When you get the instance of a particular item, you can call the disable() / enable() / etc. methods.
      function toggleButton()
      {
      	var toolBar = $find("<%= RadToolBar1.ClientID %>");
      	var text = $get("<%= TextBox1.ClientID %>").value;
      	var item = toolBar.findItemByText(text);
      
      	if (!item)
      	{
      		alert("There is no item with text \"" + text + "\"");
      		return false;
      	}
      	
      	if (!Telerik.Web.UI.RadToolBarButton.isInstanceOfType(item))
      	{
      		alert("The item with the specified text is not a button.\nOnly buttons can be checked/unchecked");
      		return false;
      	}
      
      	if (Telerik.Web.UI.IRadToolBarDropDownItem.isInstanceOfType(item.get_parent()))
      	{
      		item.get_parent().showDropDown();
      		item.toggle();
      	}
      
      	return false;
      }
      
Compatible with ASP.NET 2.0, 3.5 AJAX enabled Accessibility Verified!Valid XHTML 1.1! Optimized for Visual Studio 2005, 2008
Copyright 2002-2010 © Telerik. All right reserved  | 
Telerik Inc., 460 Totten Pond Rd, Suite 640, Waltham, MA 02451

www.telerik.com  |  Terms of Use  |  Contact Us