Custom RadToolbarButton.Text not updating

6 posts, 0 answers
  1. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 12 Dec 2014 Link to this post

    Hi,

    I have added a custom button to the RadFileExplorer.Toolbar. Within the ExplorerPopulated event of the RadFileExplorer I modify the text of the button but this change does not appear within the browser.
    eg:

    protected void Page_Load(object sender, EventArgs e)
    {
        btnSpace = new Telerik.Web.UI.RadToolBarButton();
        btnSpace.Enabled = false;
        btnSpace.CssClass = "CustomButton";
        RadFileExplorer1.ToolBar.Items.Add(btnSpace);
    }

    protected void RadFileExplorer1_ExplorerPopulated(object sender, Telerik.Web.UI.RadFileExplorerPopulatedEventArgs e)
    {
        btnSpace.Text = "hello";
    }

    How do I force the text to update?

    Thanks

    Nic
  2. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 17 Dec 2014 Link to this post

    Hi Nic,

    I tried the provided code snippet but the custom button's text is applied properly on my side - screenishot. I am attaching my test page to this message - are you able to reproduce the problem with it?

    Regards,
    Vessy
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 23 Dec 2014 in reply to Vessy Link to this post

    Hi Vessy,

    My problem seems to be that btnSpace does not exist after a postback. If I run the code in the debugger I can see all the toolbar buttons added by the FileExplorer control but not my custom button. Therefore I am unable to change the text as the control does not exist.

    Nic
  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 26 Dec 2014 Link to this post

    Hello Nic,

    Thank you for getting back with these details.

    The ExplorerPopulated event is too late to serialize the new Button text, and thus the button breaks and does not show at all. You can test that by changing the Text's value, subsequent post backs will do not update the text of the button, but the button will be visible.

    RadToolBarButton btnSpace;
     
    protected void Page_Init(object sender, EventArgs args)
    {
     
        btnSpace = new RadToolBarButton();
        btnSpace.Enabled = false;
        btnSpace.CssClass = "CustomButton";
        RadFileExplorer1.ToolBar.Items.Add(btnSpace);
        btnSpace.Text = "Initial Button";
     
    }
     
    protected void RadFileExplorer1_ExplorerPopulated(object sender, Telerik.Web.UI.RadFileExplorerPopulatedEventArgs e)
    {
        // This will apply only on initial load
        btnSpace.Text = "Loaded with ExplorerPopulated event";
    }

    I suggest using a more appropriate event to change the button's text, e.g., control's load event:

    ASP.NET
    <telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" OnLoad="RadFileExplorer1_Load">
        <Configuration ViewPaths="~/" DeletePaths="~/" UploadPaths="~/" />
    </telerik:RadFileExplorer>

    C#
    RadToolBarButton btnSpace;
     
    protected void Page_Init(object sender, EventArgs args)
    {
     
        btnSpace = new RadToolBarButton();
        btnSpace.Enabled = false;
        btnSpace.CssClass = "CustomButton";
        RadFileExplorer1.ToolBar.Items.Add(btnSpace);
        btnSpace.Text = "Initial Button";
    }
     
     
    protected void RadFileExplorer1_Load(object sender, EventArgs e)
    {
        btnSpace.Text = "hello";
    }

    Let us know if further questions arise.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Nic
    Nic avatar
    21 posts
    Member since:
    Oct 2012

    Posted 09 Jan 2015 in reply to Ianko Link to this post

    Hi Ianko,

    I guess my question has to be how can I add a custom button or other control to the File Explorer that has text I can change?

    Thanks

    Nic
  7. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 13 Jan 2015 Link to this post

    Hi Nic,

    You can try finding the button instance programmatically instead of preserving it into private variable.

    Example:

    ASP.NET
    <telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" OnExplorerPopulated="RadFileExplorer1_ExplorerPopulated">
        <Configuration ViewPaths="~/" DeletePaths="~/" UploadPaths="~/" />
    </telerik:RadFileExplorer>

    C#
    protected void Page_Init(object sender, EventArgs args)
    {
        RadToolBarButton btnSpace = new RadToolBarButton();
        btnSpace.Value = "IdentifyButton";
        btnSpace.Enabled = false;
        btnSpace.CssClass = "CustomButton";
        btnSpace.Text = "Initial Text";
        RadFileExplorer1.ToolBar.Items.Add(btnSpace);
    }
     
    protected void RadFileExplorer1_ExplorerPopulated(object sender, RadFileExplorerPopulatedEventArgs e)
    {
        RadToolBarItem btnSpace = RadFileExplorer1.ToolBar.FindItemByValue("IdentifyButton");
        btnSpace.Text = "New Text";
    }


    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017