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

When Creating RadRotator programmatically , images dont display

3 Answers 172 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Charles Faramarzirad
Top achievements
Rank 1
Charles Faramarzirad asked on 20 Aug 2008, 11:17 PM

Hi;
I'm following your suggested method of creating a rad rotator programmatically.  I get no errors, when i run the ajax enabled website, however, non of the images show...i simply get a blank page.
when i do a view source. i get:

<div id="RadRotator1" class="RadRotator radr_Default " style="width:200px;height:200px;">
	<!-- 2008.2.723.20 -->
<div class="radr_relativeWrapper"> <div class="radr_clipRegion">
<ul class="radr_itemsList"> <li class="radr_item"><div id="RadRotator1_i0"> <div><img src="/radrotator2/images/sharePointRt2.jpg" alt="RadRotator Demo" style="width:350px;border-width:0px;" /></div> </div></li>
        <li class="radr_item"><div id="RadRotator1_i1"> <div><img src="/radrotator2/images/sharePointRt1.jpg" alt="RadRotator Demo" style="width:350px;border-width:0px;" /></div> </div></li> </ul> </div><a class="radr_button radr_buttonUp" href="javascript:void(0);">&nbsp;</a><a class="radr_button radr_buttonLeft" href="javascript:void(0);">&nbsp;</a><a class="radr_button radr_buttonRight" href="javascript:void(0);">&nbsp;</a><a class="radr_button radr_buttonDown" href="javascript:void(0);">&nbsp;</a> </div><input id="RadRotator1_ClientState" name="RadRotator1_ClientState" type="hidden" /></div>









here is my code:





using

System;

using

System.Data;

using

System.Configuration;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

using

Telerik.Web.UI.Rotator;

using

System.Collections;

public

partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Telerik.Web.UI.

RadRotator rr = new Telerik.Web.UI.RadRotator();

rr.ID =

"RadRotator1";

rr.FrameDuration = 6000;

rr.InitialItemIndex = 0;

rr.ItemTemplate =

new RadRotatorTemplate();

rr.DataSource = CreateRotatorData();

rr.DataBind();

this.Controls.Add(rr);

}

private ArrayList CreateRotatorData()

{

ArrayList al = new ArrayList();

al.Add(ResolveUrl(

"~/images/sharePointRt2.jpg"));

al.Add(ResolveUrl(

"~/images/sharePointRt1.jpg"));

return al;

}

}

public

class RadRotatorTemplate : ITemplate

{

public RadRotatorTemplate() { }

#region

ITemplate Members

public void InstantiateIn(Control container)

{

LiteralControl lc1 = new LiteralControl("<div>");

container.Controls.Add(lc1);

Image img = new Image();

img.AlternateText =

"RadRotator Demo";

img.Width =

Unit.Pixel(350);

img.DataBinding += img_DataBinding;

container.Controls.Add(img);

LiteralControl lc2 = new LiteralControl("</div>");

container.Controls.Add(lc2);

}

#endregion

void img_DataBinding(object sender, EventArgs e)

{

Image img = sender as Image;

Telerik.Web.UI.

RadRotatorItem item = img.NamingContainer as Telerik.Web.UI.RadRotatorItem;

img.ImageUrl = (

string)item.DataItem;

}

}



Any help would be appreciated...
thanks
Charles






3 Answers, 1 is accepted

Sort by
0
Charles Faramarzirad
Top achievements
Rank 1
answered on 21 Aug 2008, 04:29 PM
I figured it out:

for some reason the line this.controls.add(rr); put the radrotator outside the html tag.  so i created a label tag inside the page and then I added the RadRotator to that labels control..

it works now.

thanks
charles
0
Qurat
Top achievements
Rank 1
answered on 09 Apr 2013, 11:50 AM
i used the same code it gives me this error :
Error    4    'Telerik.Web.UI.RadRotator' does not contain a definition for 'FrameTemplate' and no extension method 'FrameTemplate' accepting a first argument of type 'Telerik.Web.UI.RadRotator' could be found (are you missing a using directive or an assembly reference?)    C:\Users\hp\Downloads\061183_ProgrammaticTemplateCS\ProgrammaticTemplateCS\rotator.aspx.cs    102    22    C:\...\ProgrammaticTemplateCS\

0
Slav
Telerik team
answered on 12 Apr 2013, 08:59 AM
Hello Qurat,

As I explained in the other forum thread you used, the FrameTemplate is not available in the RadRotator for ASP.NET AJAX. Please utilize the sample that I attached there in order to configure the rotator on your end.

I would suggest using a single forum for reporting a particular problem. This way the information on the case will be easier to track. Let us continue our discussion in the linked forum thread.

Greetings,
Slav
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
Charles Faramarzirad
Top achievements
Rank 1
Answers by
Charles Faramarzirad
Top achievements
Rank 1
Qurat
Top achievements
Rank 1
Slav
Telerik team
Share this question
or