HTML Link In Rotator

5 posts, 1 answers
  1. Stuart
    Stuart avatar
    21 posts
    Member since:
    Jan 2011

    Posted 09 Jul 2012 Link to this post

    Hi All

    RadTicker1.Items.Add(new RadTickerItem("Stuart"));
               RadTicker1.Items.Add(new RadTickerItem("<a href=url>Link text</a>"));
               RadTicker1.Loop = true;         
     
               RadRotator1.Items.Add(new RadRotatorItem(RadTicker1));          
               RadRotator1.Enabled = true;
               RadRotator1.Visible = true;
               RadRotator1.RotatorType = RotatorType.AutomaticAdvance;

    This shows my Text but does not format the html link as a link it shows it as "<a href=url>Link text</a>" raw, this code is in a user control. How to I get HTML in a rotator formated? (code behind)"


    Thanks
    Stuart
  2. Niko
    Admin
    Niko avatar
    387 posts

    Posted 09 Jul 2012 Link to this post

    Hello Stuart,

     If you need to have the ticker to display links you should specify the NavigateUrl property of the respective link ticker item. Here is a sample: 
    theTicker.Items.Add(new RadTickerItem()
    {
        NavigateUrl = "http://www.bing.com",
        Text = "Bing"
    });
    theTicker.Items.Add(new RadTickerItem()
    {
        NavigateUrl = "http://www.google.com",
        Text = "Google"
    });

    Hope this helps.

    Regards,
    Niko
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stuart
    Stuart avatar
    21 posts
    Member since:
    Jan 2011

    Posted 10 Jul 2012 Link to this post

    Thanks

    How can I use HTML tags with Text i.e <b>Bold Text</b> that will be rendered on page according to the tag. Ticker only allows text to show. I have tried a few things but I think I am off the mark.



    RadRotatorItem newItem2 = new RadRotatorItem();
    RadRotatorItemData item2 = new RadRotatorItemData();
    item2.Html = "<h1>Stuart</h1>";
    newItem2.DataItem = item2;

    OR

      ArrayList description = new ArrayList();
     description.Add("<h1>Stuart</h1>");
     description.Add("<a href=http://www.w3schools.com/>Visit W3Schools</a>");
     
     foreach (string s in description)
     {
      MyURL url = new MyURL();
      url.dataDescription = s;
      RadRotator1.Items.Add(new RadRotatorItem(url));
      }
     
    public struct MyURL
        {
            public string dataDescription { get; set; }
        }
    <telerik:RadRotator ID="RadRotator1" runat="server" FrameDuration="6000">
     
     <ItemTemplate>
     <asp:Label ID="test"  Text='<%# DataBinder.Eval(Container.DataItem,"dataDescription") %>' runat="server"></asp:Label>
     </ItemTemplate>
     
     
     </telerik:RadRotator>
  5. Stuart
    Stuart avatar
    21 posts
    Member since:
    Jan 2011

    Posted 10 Jul 2012 Link to this post

    Hi Everyone

    My final solution below  including code behind.

      <style type="text/css">
        .itemTemplate
    {
        width: 100%;
        height: 30px;
    }
        </style>
     
    <telerik:RadRotator ID="radRotateTicker" runat="server" FrameDuration="6000" ScrollDirection="Up"
        Width="100%" ItemWidth="100%" Height="30" ItemHeight="30">
        <ItemTemplate>
            <div class="itemTemplate">
                <span>
                    <%# DataBinder.Eval(Container.DataItem,"dataDescription") %>
                </span>
            </div>
        </ItemTemplate>
    </telerik:RadRotator>

    foreach (NewsItem ni in newsItemCollection)
             {             
                     MyURL url = new MyURL();
                     url.dataDescription = ni.Description;
                     radRotateTicker.Items.Add(new Telerik.Web.UI.RadRotatorItem(url));
                  
             }
             
             radRotateTicker.ScrollDuration = 4000;
             radRotateTicker.FrameDuration = 6000;
             radRotateTicker.InitialItemIndex = 0;
             radRotateTicker.RotatorType = Telerik.Web.UI.RotatorType.AutomaticAdvance;
             radRotateTicker.DataBind();
     
     
         public struct MyURL
         {
             public string dataDescription { get; set; }
         }

    Thanks
  6. Answer
    Niko
    Admin
    Niko avatar
    387 posts

    Posted 10 Jul 2012 Link to this post

    Hello Stuart,

    The RadRotator control accept miscellaneous HTML content. It is the RadTicker that only accepts plain text or HTML anchor tags if NavigateUrl is specified.
    The reason why the content is not showing in the RadRotator in the first case is because the RadRotatorItemData class should be used to communicate between web services, not declarative initialization of the control - http://www.telerik.com/help/aspnet-ajax/t_telerik_web_ui_radrotatoritemdata.html.
    Your second scenario seems completely valid. I have attached a slightly modified version for you to test on your side.

    Hope this helps.

    All the best,
    Niko
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017