adding tags clientside

2 posts, 0 answers
  1. d
    d avatar
    2 posts
    Member since:
    Mar 2011

    Posted 05 Mar 2011 Link to this post

    Is there anything in the clientside api for adding and removing items?
  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 09 Mar 2011 Link to this post

    Hi,

    This functionality is not supported by the TagCloud control, but it can be easily achieved with a bit of JavaScript code. For your convenience I have created a sample project that shows how this can be done:

    Copy Code
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function AddItem()
            {
                var tagCloud = $find("TagCloud1");
     
                var liElement = document.createElement("li");
                liElement.innerHTML = "<a href='http://www.telerik.com' ref='tag' title='Telerik'>Telerik</a>";
                Sys.UI.DomElement.addCssClass(liElement, "rtcTagItem");
                tagCloud.get_containerElement().appendChild(liElement);
     
                var tagCloudItem = $create(Telerik.Web.UI.RadTagCloudItem, { navigateUrl: "http://www.telerik.com" }, null, null, liElement);
                Array.add(tagCloud.get_items(), tagCloudItem);
            }
         
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <div>
            <asp:Label ID="Label1" runat="server"></asp:Label>
            <input type="button" onclick="AddItem();" value="Add Item" />
        </div>
        <telerik:RadTagCloud ID="TagCloud1" runat="server" Width="400px">
            <Items>
                <telerik:RadTagCloudItem Text="ASP.NET" Weight="12" />
                <telerik:RadTagCloudItem Text="AJAX" Weight="134" />
                <telerik:RadTagCloudItem Text="VB" Weight="56" />
                <telerik:RadTagCloudItem Text="C#" Weight="38" />
                <telerik:RadTagCloudItem Text="Web" Weight="73" />
            </Items>
        </telerik:RadTagCloud>
        </form>
    </body>
    </html>


    All the best,
    Pero
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top