Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > FileExplorer > How to add a custom button to the toolbar and hide an existing one(s)

Not answered How to add a custom button to the toolbar and hide an existing one(s)

Feed from this thread
  • Posted on Jan 18, 2010 (permalink)

    Requirements

    RadControls version RadControls for ASP.NET AJAX 2009
    .NET version

    .NET20 & .NET35
    Visual Studio version

    2005/2008
    programming language

    C#
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    How to add a custom button to the toolbar and hide the Back and Forward buttons

    1. Create and add the custom button to the embedded RadToolBar control.
      • Server-side code:
        protected void Page_Load(object sender, EventArgs e)
        {
            RadToolBarButton propertyButton = new RadToolBarButton("Properties");
            propertyButton.Value = "PropertyButton";
            propertyButton.CssClass = "propertyBtnStyleClass";// Use CSS class in order to override the default values
           
            // The custom button will be the first button
            this.RadFileExplorer1.ToolBar.Items.Insert(0, propertyButton);
           
            // The custom button will be the last button
            //this.RadFileExplorer1.ToolBar.Items.Insert(this.RadFileExplorer1.ToolBar.Items.Count, propertyButton);
        }
      • Please note the assigned CssClass name. The implementation of the classs should be similar to:
        <style type="text/css">
            /* Set the desired properties to the custom button */
            a.propertyBtnStyleClass.rtbWrap .rtbText
            {
                font-size: 12px;
                background: url('ics.png') no-repeat left center;
            }
        </style>
    2. Hide Back and Forward buttons
      • This should be done in the Page's LoadCompleate event as shown bellow:
        protected override void OnLoadComplete(EventArgs e)
        {
            base.OnLoadComplete(e);
            HideToolBarButtons();
        }
      • The implementation of the HideToolBarButtons :
        private void HideToolBarButtons()
        {// Hides toolbar buttons
            this.RadFileExplorer1.ToolBar.Items.FindItemByValue("Back").Visible = false;
            this.RadFileExplorer1.ToolBar.Items.FindItemByValue("Forward").Visible = false;
        }
    Attached files

    Reply

  • Abdullah avatar

    Posted on Jan 31, 2012 (permalink)

    How can we handle these new added toolbar items in client side. If i want to change their enable state during runtime  when user click on a item in file explorer, how can i catch the toolbar items?

    Reply

  • Dobromir Dobromir admin's avatar

    Posted on Feb 2, 2012 (permalink)

    Hi Abdullah,

    You can access the custom toolbar buttons on the client through RadFileExplorer's client-side object using the following approach:
    var toolbar = explorer.get_toolbar();//get reference to the toolbar
    var customButton = toolbar.findItemByValue("PropertyButton");//get reference to the button with Value=PropertyButton


    All the best,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now

    Reply

  • Steven avatar

    Posted on Feb 11, 2012 (permalink)

    I followed this and the sample program and have no problem putting up the alert window when the button is clicked.  But that is client side.  Is there a way I can get a postback to handle this server side?  Just like in this sample, I want to have the properties button launch a window where I can prompt for comments and other details about the file or directory.

    Thanks

    Reply

  • Dobromir Dobromir admin's avatar

    Posted on Feb 15, 2012 (permalink)

    Hi Steven,

    In order to handle the button click on the server will require external ajaxification of RadFileExplorer, however, this is highly not recommended because RadFileExplorer's functionality is based on client-side callbacks and mixing it with ajax calls may cause unexpected errors.

    Could you please provide more detailed information on your specific scenario so we can try to provide suitable solution, if possible?

    Greetings,
    Dobromir
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Steven avatar

    Posted on Feb 15, 2012 (permalink)

    Basically what I would like is to be able to get the button click event with a postback, just as though I had created that toolbar myself, outside of the FileExplorer.  Inside that event handler, I would like to ask FileExplorer for the currently selected item so I could prompt the user for a Description and comments, and possibly even some security stuff.  I know this would be possible to do client-side with a lot of javascript, but we really like to keep our code in C# running on the server.

    Reply

  • Dobromir Dobromir admin's avatar

    Posted on Feb 16, 2012 (permalink)

    Hi Steven,

    I believe this is not the correct example for your requirements. Please take a look at the following KB articles:
    Custom field in the GridContextMenu. Pass the selected item's path to the server when the field is clicked.
    Pass all of the selected items' paths to the server

    Regards,
    Dobromir
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > FileExplorer > How to add a custom button to the toolbar and hide an existing one(s)