protected override void CreateChildControls()
{
base.CreateChildControls();
Panel panel = new Panel();
panel.ID = "Panel1";
this.Controls.Add(panel);
RadRotator rrImageRotator = new RadRotator();
rrImageRotator = new RadRotator();
rrImageRotator.ID = "rrImageRotator";
rrImageRotator.RotatorType = RotatorType.Carousel;
rrImageRotator.Width = Unit.Pixel(650);
rrImageRotator.Height = Unit.Pixel(250);
rrImageRotator.ItemHeight = Unit.Pixel(250);
rrImageRotator.ItemWidth = Unit.Pixel(250);
rrImageRotator.ItemTemplate = new RadRotatorTemplate();
rrImageRotator.DataSource = getDOCLib();
rrImageRotator.DataBind();
panel.Controls.Add(rrImageRotator);
RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page);
if (ajaxManager == null)
{
ajaxManager = new RadAjaxManager();
ajaxManager.ID = "RadAjaxManager1";
Controls.Add(ajaxManager);
this.Page.Items.Add(typeof(RadAjaxManager), ajaxManager);
}
ajaxManager.AjaxSettings.AddAjaxSetting(rrImageRotator, panel);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.ClientScript.RegisterStartupScript(typeof(SuccessStories), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
if (this.Page.Form != null)
{
string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
{
this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
}
}
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
if (scriptManager == null)
{
scriptManager = new RadScriptManager();
this.Page.Form.Controls.AddAt(0, scriptManager);
}
}
public ArrayList getDOCLib()
{
// SPSite Site = SPContext.Current.Site;
SPSite Site = new SPSite("http://");
SPWeb Web = Site.RootWeb;
SPDocumentLibrary docLib = (SPDocumentLibrary)Web.Lists["Successful Customer Stories Images"];
SPListItemCollection items = docLib.Items;
ArrayList al = new ArrayList();
foreach (SPListItem item in items)
{
string strURL = "Image URL Come's here";
//al.Add(item.File.ServerRelativeUrl);
al.Add(ResolveUrl(strURL));
}
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 = "Scusscess Stories";
img.Width = Unit.Pixel(250);
img.Height = Unit.Pixel(250);
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;
RadRotatorItem template = img.NamingContainer as RadRotatorItem;
// template.ItemTemplate = new RadRotatorTemplate();
//// RadRotatorFrame frame = img.NamingContainer as RadRotatorFrame;
// img.ImageUrl = (string)frame.DataItem;
img.ImageUrl = (string)template.DataItem;
}
}
}