New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Generating TagCloud from External Sources

  • Demo Configurator
Generate from URL
Generate from File
Generate from Plain Text
  • Combine Sources

RadTagCloud provides an easy way to generate tags from external sources. By setting the corresponding property, you can generate tags from text file, direct input (text) and from a web site. In the example above, use the first input field to set absolute URL to generate tags from a web site, use upload section to provide a text file as a source, use the text area to set text as a source.

To configure RadTagCloud to use external sources you need to set one or more of the following properties:
  • Text - sets text value for direct input generation source
  • TextFile - specifies the location of the file to be used as a generation source
  • TextUrl - specifies the URL of the web site to be used as a generation source

If more than one of these properties are set RadTagCloud will combine the sources when generating the tags.

Items generated from a text source are not considered data bound, so they will not fire the ItemDataBound event. They are created during the PreRender phase and if you need to access them, you should override the OnPreRenderComplete event.

In the Fine-tune tab of the Demo Configurator you will find options to further manage the content of the RadTagCloud control.

You can define a comma (,) separated list of words to exclude from the tags collection.

If you want to exclude a special character from the tags list, because it is a puntuaction character, you can add it in the Puntuation characters input field.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.TagCloud.ExternalSources.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxLoadingPanel ID="ajaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="ajaxLoadingPanel1">
        <div class="demo-container size-thin">
            <telerik:RadTagCloud RenderMode="Lightweight" ID="RadTagCloud1" runat="server" MaxNumberOfItems="30" TakeTopWeightedItems="true" PunctuationCharactersValid=".'#$£€<>" />
        </div>
    </telerik:RadAjaxPanel>
    <qsf:ConfiguratorPanel runat="server">
        <Views>
            <qsf:View Title="Generate content" runat="server">
                <qsf:ConfiguratorColumn Title="Generate from URL" runat="server" Size="Medium">
                    <ul class="fb-group">
                        <li>
                            <qsf:TextBox ID="urlField" runat="server" TextMode="SingleLine" ToolTip="The URL must start with http://" />
                            <asp:RegularExpressionValidator ID="urlValidator" runat="server" SetFocusOnError="true"
                                                            ErrorMessage="Valid URL should start with http://" CssClass="urlValidator" ControlToValidate="urlField"
                                                            ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?" Display="Dynamic" />
                        </li>
                        <li>
                            <qsf:Button ID="urlButton" runat="server" Text="Generate" OnClick="urlButton_Click" />
                        </li>
                    </ul>
                </qsf:ConfiguratorColumn>
                <qsf:ConfiguratorColumn Title="Generate from File" runat="server" Size="Medium">
                    <ul class="fb-group">
                        <li>
                            <telerik:RadAsyncUpload RenderMode="Lightweight" ID="fileField" runat="server" AllowedFileExtensions="txt" TargetFolder="~/TagCloud/Examples/ExternalSources/Files" />
                        </li>
                        <li>
                            <qsf:Button ID="fileButton" runat="server" Text="Generate" OnClick="fileButton_Click" />
                        </li>
                    </ul>
                </qsf:ConfiguratorColumn>
                <qsf:ConfiguratorColumn Title="Generate from Plain Text" runat="server" Size="Medium">
                    <ul class="fb-group">
                        <li>
                            <qsf:TextBox ID="directInputField" runat="server" Height="100" TextMode="MultiLine" />
                        </li>
                        <li>
                            <qsf:Button ID="directInputButton" runat="server" Text="Generate" OnClick="directInputButton_Click" />
                        </li>
                    </ul>
                </qsf:ConfiguratorColumn>
            </qsf:View>
            <qsf:View runat="server" Title="Fine-tune">
                <ul class="fb-group">
                    <li>
                        <span class="label">Combine Sources</span>
                        <asp:RadioButtonList ID="combineSources" runat="server">
                            <asp:ListItem Text="Yes" Value="1" Selected="True"></asp:ListItem>
                            <asp:ListItem Text="No" Value="0"></asp:ListItem>
                        </asp:RadioButtonList>
                    </li>
                    <li>
                        <qsf:TextBox ID="wordsToExclude" Label="Words to Exclude separated by comma (,)" runat="server" />
                    </li>
                    <li>
                        <qsf:TextBox ID="punctCharacters" Label="Puntuation Characters" runat="server" />
                    </li>
                    <li>
                        <qsf:Button ID="updateButton" Text="Update" OnClick="updateButton_Click" runat="server" />
                    </li>
                </ul>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance