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
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
0
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
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
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
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.
I suggest using a more appropriate event to change the button's text, e.g., control's load event:
ASP.NET
C#
Let us know if further questions arise.
Regards,
Ianko
Telerik
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
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
Hi Nic,
You can try finding the button instance programmatically instead of preserving it into private variable.
Example:
ASP.NET
C#
Regards,
Ianko
Telerik
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.