New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

This partial class specifies the rendering of RadToolBarButton.

When the user clicks a toolbar button, the RadToolBar control can either navigate to a linked Web page or simply post back to the server. If the NavigateUrl property of a toolbar button is set, the RadToolBar control navigates to the linked page. By default, a linked page is displayed in the same window or frame as the RadToolBar control. To display the linked content in a different window or frame, use the Target property.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class RadToolBarButton : RadToolBarItem, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IMarkableStateManager, IStateManager, INamingContainer, IXmlSerializable, ICloneable, IRadToolBarButton

Inheritance: objectControlWebControlControlItemRadToolBarItemRadToolBarButton...

Implements: IAttributeAccessorICloneableIComponentIControlBuilderAccessorIControlDesignerAccessorIDataBindingsAccessorIDisposableIExpressionsAccessorIMarkableStateManagerINamingContainerIParserAccessorIRadToolBarButtonIStateManagerIUrlResolutionServiceIXmlSerializable...

Inherited Members RadToolBarItem.RenderContents(HtmlTextWriter)RadToolBarItem.AddAttributesToRender(HtmlTextWriter)RadToolBarItem.WriteXmlForChildren(XmlWriter, RadToolBarItemCollection)RadToolBarItem.ReadXmlForChildren(XmlReader)RadToolBarItem.TagKeyRadToolBarItem.ItemRendererRadToolBarItem.ToolBarRadToolBarItem.TextRadToolBarItem.IDRadToolBarItem.ImageUrlRadToolBarItem.HoveredImageUrlRadToolBarItem.SpriteCssClassRadToolBarItem.HoveredCssClassRadToolBarItem.ClickedCssClassRadToolBarItem.ClickedImageUrlRadToolBarItem.DisabledImageUrlRadToolBarItem.DisabledCssClassRadToolBarItem.FocusedCssClassRadToolBarItem.FocusedImageUrlRadToolBarItem.OuterCssClassRadToolBarItem.ImagePositionRadToolBarItem.EnableImageSpriteRadToolBarItem.OverFlowRadToolBarItem.ShowTextRadToolBarItem.ShowImageControlItem.SetChildrenDirty()ControlItem.LoadChildViewState(object)ControlItem.SaveChildViewState()ControlItem.TrackChildViewState()ControlItem.GetHierarchicalIndex()ControlItem.ReadXml(XmlReader)ControlItem.WriteXml(XmlWriter)ControlItem.IsChildControl(Control)ControlItem.GetAllChildren<TControlItem>()ControlItem.GetChildren<TControlItem>(Predicate<TControlItem>)ControlItem.FindChild<TControlItem>(Predicate<TControlItem>)ControlItem.IndexControlItem.AccessKeyControlItem.TemplateControlItem.ContainerControlItem.RenderingCompatibilityControlItem.ChildrenControlItem.PropertyMappingsWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.CreateControlStyle()WebControl.LoadViewState(object)WebControl.TrackViewState()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderBeginTag(HtmlTextWriter)WebControl.RenderEndTag(HtmlTextWriter)WebControl.SaveViewState()WebControl.AttributesWebControl.BackColorWebControl.BorderColorWebControl.BorderWidthWebControl.BorderStyleWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.CssClassWebControl.StyleWebControl.EnabledWebControl.EnableThemingWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.HeightWebControl.IsEnabledWebControl.SupportsDisabledAttributeWebControl.SkinIDWebControl.TabIndexWebControl.TagNameWebControl.ToolTipWebControl.WidthControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind()Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.OnInit(EventArgs)Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.Focus()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.OnLoad(EventArgs)Control.OnPreRender(EventArgs)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderChildren(HtmlTextWriter)Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.Dispose()Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.AddedControl(Control, int)Control.CreateControlCollection()Control.CreateChildControls()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.HasControls()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IsChildControlStateClearedControl.EnableViewStateControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.VisibleControl.UniqueIDControl.HasChildViewStateControl.ControlsControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

Initializes a new instance of the RadToolBarButton class.

C#
public RadToolBarButton()

Use this constructor to create and initialize a new instance of the RadToolBarButton class using default values.

Example:
cs-api-definition
RadToolBarButton button = new RadToolBarButton();
button.Text = "Create New";
button.CommandName = "CreateNew";
button.ImageUrl = "~/ToolBarImages/CreateNew.gif";

RadToolBar1.Items.Add(button);

Initializes a new instance of the RadToolBarButton class with the specified text, checked state and group name data.

C#
public RadToolBarButton(string text, bool isChecked, string group)
Parameters:textstring

The text of the button. The Text property is set to the value of this parameter.

isCheckedbool

The checked state of the button. The Checked property is set to the value of this parameter.

groupstring

The group to which the button belongs. The Group property is set to the value of this parameter.

Use this constructor to create and initialize a new instance of the RadToolBarButton class using the specified text, checked state and group name.

When this constructor used, the CheckOnClick property of the created RadToolBarButton is automatically set to true.

Example:
cs-api-definition
RadToolBarButton alighLeftButton = new RadToolBarButton("Left", false, "Alignment");
alighLeftButton.CommandName = "AlignLeft";
alighLeftButton.ImageUrl = "~/ToolBarImages/AlignLeft.gif";
RadToolBar1.Items.Add(alighLeftButton);

RadToolBarButton alignCenterButton = new RadToolBarButton("Center", false, "Alignment");
alignCenterButton.CommandName = "AlignCenter";
alignCenterButton.ImageUrl = "~/ToolBarImages/AlignCenter.gif";
RadToolBar1.Items.Add(alignCenterButton);

RadToolBarButton alignRightButton = new RadToolBarButton("Right", false, "Alignment");
alignRightButton.CommandName = "AlignRight";
alignRightButton.ImageUrl = "~/ToolBarImages/AlignRight.gif";
RadToolBar1.Items.Add(alignRightButton);

Initializes a new instance of the RadToolBarButton class with the specified text data.

C#
public RadToolBarButton(string text)
Parameters:textstring

The text of the button. The Text property is set to the value of this parameter.

Use this constructor to create and initialize a new instance of the RadToolBarButton class using the specified text.

Example:
cs-api-definition
RadToolBarButton button = new RadToolBarButton("Create New");
button.CommandName = "CreateNew";
button.ImageUrl = "~/ToolBarImages/CreateNew.gif";

RadToolBar1.Items.Add(button);

Properties

Gets or sets a value indicating if a checked button will get unchecked when clicked.

C#
public bool AllowSelfUnCheck { get; set; }
Property Value:

If a checked button will get unchecked when clicked. The default value is false.

Gets or sets a value indicating whether validation is performed when the RadToolBarButton is clicked

C#
public bool CausesValidation { get; set; }
Property Value:

true if validation is performed when the RadToolBarButton is clicked otherwise, false. The default value is true.

Implements: IRadToolBarButton.CausesValidation

By default, page validation is performed when the button is clicked. Page validation determines whether the input controls associated with a validation control on the page all pass the validation rules specified by the validation control. You can specify or determine whether validation is performed when the button is clicked on both the client and the server by using the CausesValidation property. To prevent validation from being performed, set the CausesValidation property to false.

Gets or sets if the button is checked.

C#
public bool Checked { get; set; }

The Checked property of the button depends on the CheckOnClick property. If the CheckOnClick property is set to false, the Checked property will be ignored.

When a button's Checked state is set to true, all the buttons that belong to the same group in the RadToolBar get their Checked state set to false.

Gets or sets the Cascading Style Sheet (CSS) class applied when the toolbar button is checked.

C#
public string CheckedCssClass { get; set; }
Property Value:

The CSS class applied when the toolbar button is checked. The default value is string.Empty.

Example:
C#
By default the visual appearance of clicked toolbar buttons is defined in the skin CSS
file. You can use the <strong>ClickedCssClass</strong> property to specify unique
appearance for the toolbar button when it is clicked.

Gets or sets the path to an image to display for the button when its Checked state is "true".

C#
public string CheckedImageUrl { get; set; }
Property Value:

The path to the image to display when its Checked state is "true". The default value is empty string.

Use the CheckedImageUrl property to specify the image that will be used when the button is checked. If the CheckedImageUrl property is set to empty string the image specified by the ImageUrl property will be used. Use "~" (tilde) when referring to images within the current ASP.NET application.

Example:
C#
<p>&lt;telerik:RadToolBar id="RadToolBar1" runat="server"&gt;<br />
&lt;Items&gt;<br />
&lt;telerik:RadToolBarButton ImageUrl="~/Img/alignLeft.gif"
<strong>CheckedImageUrl="~/Img/alignLeftChecked.gif"</strong> Text="Left" /&gt;<br />
&lt;telerik:RadToolBarButton ImageUrl="~/Img/alignRight.gif"
<strong>CheckedImageUrl="~/Img/alignRightChecked.gif"</strong> Text="Right"
/&gt;<br />
&lt;/Items&gt;<br />
&lt;/telerik:RadToolBar&gt;</p>

Gets or sets whether the button has a check state.

C#
public bool CheckOnClick { get; set; }

Gets or sets an optional parameter passed to the Command event of the RadToolBar instance along with the associated CommandName

C#
public string CommandArgument { get; set; }
Property Value:

An optional parameter passed to the Command event of the RadToolBar instance along with the associated CommandName. The default value is an empty string.

Implements: IRadToolBarButton.CommandArgument

Gets or sets the command name associated with the toolbar button that is passed to the ItemCommand event of the RadToolBar instance.

C#
public string CommandName { get; set; }
Property Value:

The command name of the toolbar button. The default value is an empty string.

Implements: IRadToolBarButton.CommandName

Gets the data item that is bound to the button

C#
[Browsable(false)]
public override object DataItem { get; set; }
Property Value:

An Object that represents the data item that is bound to the button. The default value is null (Nothing in Visual Basic), which indicates that the button is not bound to any data item. The return value will always be null unless accessed within a ButtonDataBound event handler.

Overrides: ControlItem.DataItem

This property is applicable only during data binding. Use it along with the ButtonDataBound event to perform additional mapping of fields from the data item to RadToolBarButton properties.

Example:
cs-api-definition
private void RadToolBar1_ButtonDataBound(object sender, Telerik.Web.UI.RadToolBarButtonEventArgs e)
{
e.Button.ImageUrl = "image" + (string)DataBinder.Eval(e.Button.DataItem, "ID") + ".gif";
e.Button.NavigateUrl = (string)DataBinder.Eval(e.Button.DataItem, "URL");
}

Gets or sets the group to which the button belongs.

C#
public string Group { get; set; }

The Group property of the button depends on the CheckOnClick property. When several buttons in the RadToolBar are assigned to the same group, checking one of them will uncheck the one that is currently checked. If the CheckOnClick property is set to false, the Group property will be ignored.

Gets or sets whether the button is separator.

C#
public bool IsSeparator { get; set; }

Gets or sets the template for displaying the button.

C#
[TemplateContainer(typeof(RadToolBarButton))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Browsable(false)]
[Bindable(false)]
public ITemplate ItemTemplate { get; set; }
Property Value:

A ITemplate implemented object that contains the template for displaying the item. The default value is a null reference (Nothing in Visual Basic), which indicates that this property is not set.

Implements: IRadToolBarButton.ItemTemplate

Example:
C#
<p>The following template demonstrates how to add a Calendar control in a certain
ToolBar button.</p>
<p>ASPX:</p>
<p>&lt;telerik:RadToolBar runat="server" ID="RadToolBar1"&gt;</p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
    <p>&lt;Items&gt;</p>
    <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
        <p>&lt;telerik:RadToolBarDropDown Text="Date"&gt;</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
            <p>&lt;Items&gt;</p>
                <p>&lt;telerik:RadToolBarButton Text="Date"&gt;</p>
                    <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
                        <p>&lt;ItemTemplate&gt;</p>
                        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
                            <p>&lt;asp:Calendar runat="server" ID="Calendar1"
                               /&gt;</p>
                        </blockquote>
                        <p>&lt;/ItemTemplate&gt;</p>
                    </blockquote>
                   <p>&lt;/telerik:RadToolBarDropButton&gt;</p>
            <p>&lt;/Items&gt;</p>
        </blockquote>
        <p>&lt;/telerik:RadToolBarDropDown&gt;</p>
    </blockquote>
    <p>&lt;/Items&gt;</p>
</blockquote>
<p>&lt;/telerik:RadToolBar&gt;</p>

Gets or sets the URL to link to when the button is clicked.

C#
[Bindable(true)]
public string NavigateUrl { get; set; }
Property Value:

The URL to link to when the button is clicked. The default value is empty string.

Implements: IRadToolBarButton.NavigateUrl

Use the NavigateUrl property to specify the URL to link to when the button is clicked. Use "~" (tilde) in front of an URL within the same ASP.NET application. When specifying external URL do not forget the protocol (e.g. "http://").

Example:
C#
The following example demonstrates how to use the <strong>NavigateUrl</strong>
property

<p>
    <p>&lt;telerik:RadToolBar id="RadToolBar1"
    runat="server"&gt;<br />
    &lt;Items&gt;<br />
    &lt;telerik:RadToolBarButton Text="News" <strong>NavigateUrl="~/News.aspx"</strong>
    /&gt;<br />
    &lt;telerik:RadToolBarButton Text="External URL"
    <strong>NavigateUrl="http://www.example.com"</strong> /&gt;<br />
    &lt;/Items&gt;<br />
    &lt;/telerik:RadToolBar&gt;</p>
</p>

Gets a reference to the owner of the RadToolBarButton.

C#
[Browsable(false)]
[Bindable(false)]
public IRadToolBarItemContainer Owner { get; }
Property Value:

The IToolBarItemContainer control (RadToolBar, RadToolBarDropDown, RadToolBarSplitButton) which holds the RadToolBarButton.

Gets or sets a value indicating whether clicking on the button will postback.

C#
public bool PostBack { get; set; }
Property Value:

True if the toolbar button should postback; otherwise false. By default all the items will postback provided the user has subscribed to the ButtonClick event.

Implements: IRadToolBarButton.PostBack

If you subscribe to the ButtonClick all toolbar buttons will postback. To turn off that behavior you should set the PostBack property to false.

Gets or sets the URL of the page to post to from the current page when the RadToolBarButton is clicked.

C#
public string PostBackUrl { get; set; }
Property Value:

The URL of the Web page to post to from the current page when the RadToolBarButton is clicked. The default value is an empty string (""), which causes the page to post back to itself.

Implements: IRadToolBarButton.PostBackUrl

Gets or sets the target window or frame to display the Web page content linked to when the toolbar button is clicked.

C#
[TypeConverter(typeof(TargetConverter))]
public string Target { get; set; }
Property Value:

The target window or frame to load the Web page linked to when the button is selected. Values must begin with a letter in the range of a through z (case insensitive), except for the following special values, which begin with an underscore:

The default value is empty string.

Implements: IRadToolBarButton.Target

Use the Target property to specify the frame or window that displays the Web page linked to when the toolbar button is clicked. The Web page is specified by setting the NavigateUrl property.

If this property is not set, the Web page specified by the NavigateUrl property is loaded in the current window.

Example:
C#
<p>The following example demonstrates how to use the <strong>Target</strong>
property</p>
<p>ASPX:</p>
<p>&lt;telerik:RadToolBar runat="server" ID="RadToolBar1"&gt;</p>
<p>&lt;Items&gt;</p>
<p>&lt;telerik:RadToolBarButton <strong>Target="_blank"</strong>
NavigateUrl="http://www.google.com" /&gt;</p>
<p>&lt;/Items&gt;</p>
<p>&lt;/telerik:RadToolBar&gt;</p>

Gets or sets the name of the validation group to which the RadToolBarButton belongs.

C#
public string ValidationGroup { get; set; }
Property Value:

The name of the validation group to which this RadToolBarButton belongs. The default is an empty string (""), which indicates that this property is not set.

Implements: IRadToolBarButton.ValidationGroup

This property works only when CausesValidation is set to true.

Gets or sets the value associated with the toolbar button.

C#
public override string Value { get; set; }
Property Value:

The value associated with the button. The default value is empty string.

Overrides: ControlItem.Value

Implements: IRadToolBarButton.Value

Use the Value property to specify or determine the value associated with the button.

Methods

Creates a copy of the current RadToolBarButton object.

C#
public RadToolBarButton Clone()
Returns:

RadToolBarButton

A RadToolBarButton which is a copy of the current one.

Use the Clone method to create a copy of the current button. All properties of the clone are set to the same values as the current ones.

C#
protected override ControlItemCollection CreateChildItemCollection()
Returns:

ControlItemCollection

Overrides: ControlItem.CreateChildItemCollection()

C#
protected override RadToolBarItem.RendererBase CreateRenderer()
Returns:

RadToolBarItem.RendererBase

Overrides: RadToolBarItem.CreateRenderer()

C#
protected override string GetCurrentImageUrl()
Returns:

string

Overrides: RadToolBarItem.GetCurrentImageUrl()

C#
protected override void LoadFromDictionary(IDictionary<string, object> dictionary)
Parameters:dictionaryIDictionary<string, object>

Overrides: RadToolBarItem.LoadFromDictionary(IDictionary<string, object>)

C#
protected override void SetItemContainer(ControlItemContainer itemContainer)
Parameters:itemContainerControlItemContainer

Overrides: ControlItem.SetItemContainer(ControlItemContainer)