This is a migrated thread and some comments may be shown as answers.

Custom RadToolbarButton.Text not updating

5 Answers 86 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Nic
Top achievements
Rank 1
Nic asked on 12 Dec 2014, 02:57 PM
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

5 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 17 Dec 2014, 12:23 PM
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.

 
0
Nic
Top achievements
Rank 1
answered on 23 Dec 2014, 11:07 AM
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
0
Ianko
Telerik team
answered on 26 Dec 2014, 07:57 AM
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.

 
0
Nic
Top achievements
Rank 1
answered on 09 Jan 2015, 01:00 PM
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
0
Ianko
Telerik team
answered on 13 Jan 2015, 06:52 AM
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.

 
Tags
FileExplorer
Asked by
Nic
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Nic
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or