Custom Links
The RadEditor Custom Links dropdown is a convenient tool for inserting pre-defined hyperlinks. These usually be one of two link types:
-
Internal site links (i.e. links to other pages of the web-site). You can preload the Custom Links treeview with the complete structure of your site so that the end-users would just need to select a page from the dropdown (e.g."About-us -> History").
-
Frequently used external links (e.g. Google).
Custom links are kept in the Links collection. You can add a new custom link to the Links collection declaratively, programmatically and using the ToolsFile.
Using the Links Collection Declaratively
The example below demonstrates how to add a sublist in the Custom Links dropdown treeview. The parent node is the Telerik link and its childs are Telerik Products, Telerik Support Center and Telerik Community:
<telerik:radeditor runat="server" ID="RadEditor1">
<Links>
<telerik:EditorLink Name="Telerik" Href="https://www.telerik.com">
<telerik:EditorLink Name="Telerik Products" Href="https://www.telerik.com/products" Target="_blank" />
<telerik:EditorLink Name="Telerik Support Center" Href="https://www.telerik.com/support/home.aspx" Target="_blank" />
<telerik:EditorLink Name="Telerik Community" Href="https://www.telerik.com/community/home.aspx" Target="_blank" ToolTip="Telerik Community" />
</telerik:EditorLink>
</Links>
</telerik:radeditor>
Using Links Programmatically
In the following example, we construct a simple 3-level Custom Links treeview:
RadEditor1.Links.Clear();
Telerik.Web.UI.EditorLink telerik = new Telerik.Web.UI.EditorLink();
telerik.Name = "Telerik";
telerik.Href = "https://www.telerik.com/products";
telerik.ToolTip = "Telerik";
Telerik.Web.UI.EditorLink support = new Telerik.Web.UI.EditorLink();
support.Name = "Telerik Support";
support.Href = "https://www.telerik.com/support/home.aspx";
support.ToolTip = "Telerik Support Center";
Telerik.Web.UI.EditorLink forums = new Telerik.Web.UI.EditorLink();
forums.Name = "Telerik Forums";
forums.Href = "https://www.telerik.com/forums";
forums.ToolTip = "Telerik Forums";
RadEditor1.Links.Add(telerik); // Adds the telerik link to the Links dropdown
telerik.ChildLinks.Add(support); //Adds the support link as a child of the telerik link
support.ChildLinks.Add(forums); //Adds the forums link as a child of the support link
Using the ToolsFile
You can also populate the Custom Links treeview using the ToolsFile.xml file, as shown in the example below:
<root>
<tools name="MainToolbar" enabled="true">
<tool name="InsertCustomLink" />
</tools>
<links>
<link name="Telerik" href="https://www.telerik.com">
<link name="Products" href="https://www.telerik.com/products">
<link name="Telerik® UI for ASP.NET AJAX suite" href="https://www.telerik.com/radcontrols" />
<link name="Telerik RadNavigation suite" href="https://www.telerik.com/radnavigation" />
<link name="Telerik RadEditor" href="https://www.telerik.com/radeditor">
<link name="QSF" href="https://www.telerik.com/Telerik RadEditor"/>
</link>
</link>
<link name="Purchase" href="https://www.telerik.com/purchase" />
<link name="Support" href="https://www.telerik.com/support" />
<link name="Client.Net" href="https://www.telerik.com/clientnet" />
</link>
</links>
</root>
Please bear in mind that RadEditor will persist its state (including the Custom Links set) between post backs. In order to create a new set of Custom Links (e.g. for different users), you will need to clear it first. This can be done using Remove() or Clear() methods of the Links collection.