This is a migrated thread and some comments may be shown as answers.

HTML Link In Rotator

4 Answers 121 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 09 Jul 2012, 02:54 PM
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

4 Answers, 1 is accepted

Sort by
0
Niko
Telerik team
answered on 09 Jul 2012, 04:35 PM
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.
0
Stuart
Top achievements
Rank 1
answered on 10 Jul 2012, 08:10 AM
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>
0
Stuart
Top achievements
Rank 1
answered on 10 Jul 2012, 09:31 AM
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
0
Accepted
Niko
Telerik team
answered on 10 Jul 2012, 11:03 AM
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.
Tags
Rotator
Asked by
Stuart
Top achievements
Rank 1
Answers by
Niko
Telerik team
Stuart
Top achievements
Rank 1
Share this question
or