Access the controls in the FileBrowser dialogs of RadEditor
Environment
Product | RadEditor for ASP.NET AJAX |
Description
See how to get a reference to the FileExplorer, the Grid, and AsyncUpload inside the Image Manager, Document Manager, or another File Browser dialogs of RadEditor
Solution
- Register the external dialog files of RadEditor
- Copy the EditorDialogs installation folder to the root of the web project
-
Set the ExternalDialogsPath="~/EditorDialogs/" property ro point to the EditorDialogs folder, e.g.
<telerik:radeditor runat="server" ExternalDialogsPath="~/EditorDialogs" ID="RadEditor1"> <ImageManager ViewPaths="~/" UploadPaths="~/" /> </telerik:radeditor> ````
- Create a UserControl in the root of your web application for example named UserControl.ascx and define the FindRadControl function which iterates through the Controls collection and looks for RadFileExplorer and its sub-controls:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserControl.ascx.cs" Inherits="UserControl" %> <script runat="server" type="text/C#"> protected void Page_Load(object sender, System.EventArgs args) { Telerik.Web.UI.RadFileExplorer rfe = (Telerik.Web.UI.RadFileExplorer)this.FindRadControl(this.Page); //gives a reference to RadFileExplorer if (rfe != null) { rfe.AsyncUpload.TabIndex = 2; //returns a reference to RadAsyncUpload rfe.Grid.TabIndex = 0; //returns a reference to RadGrid rfe.TreeView.EnableAriaSupport = true; //returns a reference to RadTreeView } } private Control FindRadControl(Control parent) { foreach (Control c in parent.Controls) { if (c is Telerik.Web.UI.RadFileExplorer) return c; if (c.Controls.Count > 0) { Control sub = FindRadControl(c); if (sub != null) return sub; } } return null; } </script>
- Register the custom control in the \EditorDialogs\FileBrowser.ascx external dialog control:
- Create a UserControl in the root of your web application for example named UserControl.ascx and define the FindRadControl function which iterates through the Controls collection and looks for RadFileExplorer and its sub-controls:
<%@ Register TagPrefix="custom" TagName="customControl" Src="~/UserControl.ascx" %>
<custom:customControl ID="customControl1" runat="server" />