Hello ,
I have created custom web part in asp.net for moss 2007 site.I am using RadRotator inside user control and loading it through RadAjaxPanel dynamically.It is working only in IE browser, It is not working in FF,crome 3.0 and safari 4.0.
I am using Telerik 2009.3.1208.20 version of dlls.
Following code using for user control:
<asp:Panel runat="server" ID="demo">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" valign="top" scope="col">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" scope="col" class="prismbannerTopleft">
</td>
<td align="left" valign="top" scope="col" class="prism_bannerTopMiddle">
</td>
<td align="left" valign="top" scope="col" class="prismbannerTopRight">
</td>
</tr>
<tr>
<td align="left" valign="top" scope="col" class="prism_bannerMiddleleft">
</td>
<td align="left" valign="top" scope="col">
<telerik:RadRotator ID="rrMonths" runat="server" AutoPostBack="false" OnItemDataBound="rrMonths_ItemDataBound"
ScrollDuration="2000">
<ItemTemplate>
<table>
<tr>
<td valign="top">
<asp:Label ID="lblleft" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"LeftText")%>'></asp:Label>
</td>
<td style="width:7px">
</td>
<td valign="top">
<asp:Image AlternateText="IMAGE" ID="Image1" runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"Image1")%>' Height="200" Width ="300"/>
<asp:Image AlternateText="IMAGE" ID="Image2" runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"Image2")%>' Height="100" Width ="150"/>
<asp:Image AlternateText="IMAGE" ID="Image3" runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"Image3")%>' Height="90" Width ="130"/>
<asp:HiddenField ID="hdnid" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"Id")%>'/>
</td>
<td style="width:7px" >
</td>
<td valign="top">
<asp:Label ID="lblright" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"RightText")%>'></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</telerik:RadRotator>
</td>
<td align="left" valign="top" scope="col" class="prism_bannerMiddleRight">
</td>
</tr>
<tr>
<td align="left" valign="top" scope="col" class="prism_bannerBottomleft">
</td>
<td align="left" valign="middle" scope="col" class="prismbannerBottomtext">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="72%" height="30" align="right" valign="middle" scope="col">
<asp:Panel runat="server" ID="PanelNumber" Width="200" HorizontalAlign="Right">
</asp:Panel>
</td>
</tr>
</table>
</td>
<td align="left" valign="top" scope="col" class="prism_bannerBottomRight">
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Panel>
Code behind (rotator.cs)
UC_Rotator UCRotator;
RadAjaxPanel _updatePanel;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (ScriptManager.GetCurrent(this.Page) == null)
{
ScriptManager managers = new RadScriptManager();
this.Page.Form.Controls.AddAt(0, managers);
}
}
protected override void OnLoad(EventArgs e)
{
try
{
base.OnLoad(e);
_updatePanel = new RadAjaxPanel();
_updatePanel.ID = "UpdatePanel1";
this.Controls.Add(_updatePanel);
Panel pnlsearch = (Panel)UCRotator.FindControl("demo");
_updatePanel.Controls.Add(pnlsearch);
}
catch (Exception ex)
{
HttpContext.Current.Response.Write("Error :" + ex.Message);
}
}
private void EnsureUpdatePanelFixups()
{
if (this.Page.Form != null)
{
String fixupScript = @"_spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
function _initFormActionAjax()
{
if (_spEscapedFormAction == document.forms[0].action)
{
document.forms[0]._initialAction =
document.forms[0].action;
}
}
var RestoreToOriginalFormActionCore =
RestoreToOriginalFormAction;
RestoreToOriginalFormAction = function()
{
if (_spOriginalFormAction != null)
{
RestoreToOriginalFormActionCore();
document.forms[0]._initialAction =
document.forms[0].action;
}
}";
ScriptManager.RegisterStartupScript(this, typeof(Rotator), "UpdatePanelFixup", fixupScript, true);
}
}
protected override void CreateChildControls()
{
try
{
if (BrowserDesignMode)
{
//nothing
}
else
{
base.CreateChildControls();
this.EnsureUpdatePanelFixups();
UCRotator = (UC_Rotator)this.Page.LoadControl(@"~/_CONTROLTEMPLATES/Smithsonian Controls/UC_Rotator.ascx");
UCRotator.ID = "UCRotator";
UCRotator.Rheight = this.Rheight;
UCRotator.Rwidth = this.Rwidth;
UCRotator.Itemheight = this.Itemheight;
UCRotator.Itemwidth = this.Itemwidth;
UCRotator.Home = this.Home;
UCRotator.FrameSize = this.FrameSize;
this.Controls.Add(UCRotator);
ViewState["demo"] = "true";
}
}
catch (Exception oEx)
{
throw oEx;
}
finally
{
}
}
User control code behind(UC_rotator.ascx.cs)
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (FrameSize == null)
{
lblmsg.Text = "Configure Tool Part Properties";
demo.Visible = false;
}
else
{
demo.Visible = true;
if (Home == "True")
{
rrMonths.RotatorType = Telerik.Web.UI.RotatorType.AutomaticAdvance;
}
else
{
rrMonths.RotatorType = Telerik.Web.UI.RotatorType.FromCode;
}
ListName = "Feature Content Media Gallary";
rrMonths.DataSource = GetPicDataTable();
rrMonths.DataBind();
DynamicCreateLinkButton();
if (FrameSize != null)
{
if (FrameSize == "Large")
{
demo.Width = 652;
rrMonths.Width = 652 - 41;
rrMonths.ItemWidth = 652 - 41;
rrMonths.Height = 220;
rrMonths.ItemHeight = 220;
}
else if (FrameSize == "Medium")
{
demo.Width = 406;
rrMonths.Width = 406 - 41;
rrMonths.ItemWidth = 406 - 41;
rrMonths.Height = 220;
rrMonths.ItemHeight = 220;
}
else if (FrameSize == "Small")
{
demo.Width = 376;
rrMonths.Width = 376 - 41;
rrMonths.Height = 220;
rrMonths.ItemWidth = 376 - 41;
rrMonths.ItemHeight = 220;
}
}
}
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Page Load :" + oEx.Message);
}
}
private DataTable GetPicDataTable()
{
DataTable dt = new DataTable();
DataRow dr;
DataColumn dc = new DataColumn();
dc.ColumnName = "Image1";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "Image2";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "Image3";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "Id";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "LeftText";
dt.Columns.Add(dc);
dc = new DataColumn();
dc.ColumnName = "RightText";
dt.Columns.Add(dc);
try
{
SPList oList;
SPSite tmpSite1 = SPContext.Current.Site;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(SPContext.Current.Web.Url))
{
SPWebApplication webApplication = oSite.WebApplication;
string connectionInfo = System.Configuration.ConfigurationManager.AppSettings["SetWebAppIndex"];
int WebAppIndex = int.Parse(connectionInfo);
string TopLevelSiteUrl = webApplication.Sites[WebAppIndex].Url;
using (SPWeb oWeb = oSite.OpenWeb())
{
oWeb.AllowUnsafeUpdates = true;
oList = SPContext.Current.Web.Lists[ListName];
SPQuery oQuery = new SPQuery();
if ((TopLevelSiteUrl) == (SPContext.Current.Web.Url))
{
// oQuery.Query = "<Where><Eq><FieldRef Name='ApprovalStatus' /><Value Type='Choice'>Approved</Value></Eq></Where>";
oQuery.Query = "<Where><Eq><FieldRef Name='HomeImag' /><Value Type='WorkflowStatus'>16</Value></Eq></Where>";
}
else
{
oQuery.Query = "<OrderBy><FieldRef Name='ID' /></OrderBy>";
}
SPListItemCollection oItems = oList.GetItems(oQuery);
cnt = oItems.Count;
TotalItemCount = oItems.Count;
foreach (SPListItem oItem in oItems)
{
oItem["Preview"] = oWeb.Url + @"/" + oItem.File.ToString();
string temp = Convert.ToString(oItem["Preview"]);
finalPic = finalPic + "," + temp;
string ids = Convert.ToString(oItem["ID"]);
AdminId = AdminId + "," + ids;
string temptxt = Convert.ToString(oItem["Message"]);
Txt = Txt + "^" + temptxt;
string Direction = Convert.ToString(oItem["Content Direction"]);
dir = dir + "," + Direction;
}
string[] stringList = new string[cnt];
string[] IdList = new string[cnt];
// string[] TextList = new string[cnt];
char mychar = ',';
char mychar1 = '^';
string NewfinalString = finalPic.TrimStart(mychar);
string[] batchlist = NewfinalString.Split(new Char[] { ',' });
string NewfinalStringid = AdminId.TrimStart(mychar);
string[] AdminIdList = NewfinalStringid.Split(new Char[] { ',' });
string NewfinalText = Txt.TrimStart(mychar1);
string[] TextList = NewfinalText.Split(new Char[] { '^' });
string NewfinalDir = dir.TrimStart(mychar);
string[] DirList = NewfinalDir.Split(new Char[] { ',' });
for (int i = 0; i < cnt; i++)
{
dr = dt.NewRow();
if (FrameSize != null)
{
if (FrameSize == "Large")
{
dr["Image1"] = (batchlist[i] + "");
dr["Image2"] = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/arrow_white.gif";
dr["Image3"] = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/arrow_white.gif";
}
else if (FrameSize == "Medium")
{
dr["Image1"] = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/arrow_white.gif";
dr["Image2"] = (batchlist[i] + "");
dr["Image3"] = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/arrow_white.gif";
}
else if (FrameSize == "Small")
{
dr["Image3"] = (batchlist[i] + "");
dr["Image1"] = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/arrow_white.gif";
dr["Image2"] = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/arrow_white.gif";
}
}
dr["Id"] = (AdminIdList[i] + "");
if((DirList[i].ToString()) == "Left")
{
dr["LeftText"] = (TextList[i] + "");
dr["RightText"] = "";
}
else
{
dr["LeftText"] = "";
dr["RightText"] = (TextList[i] + "");
}
// dr["Text"] = (TextList[i] + "");
dt.Rows.Add(dr);
}
}
}
});
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Get Pic Data Table :" + oEx.Message);
}
return dt;
}
protected void SetInaitialItemIndex(object sender, EventArgs e)
{
try
{
LinkButton senderControl = sender as LinkButton;
// senderControl.CssClass = "prismimagelinkSelected";
string indexAsString = senderControl.Text; // Get the value - it should be a number;
int initialIndex = int.Parse(senderControl.Text);// Parse to int
initialIndex = initialIndex - 1;
rrMonths.InitialItemIndex = initialIndex;// Assign the new value ;
if (initialIndex > 4)
{
SetNode(indexAsString);
}
else
{
SetInNode(indexAsString);
}
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Set Inaitial Item Index :" + oEx.Message);
}
}
public void DynamicCreateLinkButton()
{
try
{
ImageButton imgleft = new ImageButton();
imgleft.ImageUrl = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/prism_left_arrow.jpg";
imgleft.ImageAlign = System.Web.UI.WebControls.ImageAlign.Middle;
imgleft.Click += new System.Web.UI.ImageClickEventHandler(SetInVisible);
PanelNumber.Controls.Add(imgleft);
Label lbldemo = new Label();
lbldemo.Text = " ";
PanelNumber.Controls.Add(lbldemo);
for (int i = 1; i <= TotalItemCount; i++)
{
lnk = new LinkButton();
lnk.ID = "LinkButton" + i.ToString();
lnk.Text = i.ToString();
lnk.BorderWidth = 1;
lnk.Style.Add("text-decoration", "none");
lnk.ForeColor = System.Drawing.Color.White;
lnk.Style.Add("margin-right", "3");
lnk.Style.Add("margin-left", "3");
lnk.CssClass = "prismimagelink";
lnk.Click += new EventHandler(SetInaitialItemIndex);
PanelNumber.Controls.Add(lnk);
if (i > 5)
{
lnk.Visible = false;
}
if (i > 10)
{
lnk.Visible = false;
}
}
Label lbldemo1 = new Label();
lbldemo1.Text = " ";
PanelNumber.Controls.Add(lbldemo1);
ImageButton imgright = new ImageButton();
imgright.ImageUrl = "/_LAYOUTS/1033/IMAGES/Smithsonian Images/Feature Content/prism_right_arrow.jpg";
imgright.Style.Add("vertical-align", "left");
imgright.ImageAlign = System.Web.UI.WebControls.ImageAlign.Middle;
PanelNumber.Controls.Add(imgright);
imgright.Click += new System.Web.UI.ImageClickEventHandler(SetVisible);
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Dynamic Create Link Button :" + oEx.Message);
}
}
protected void SetVisible(object sender, EventArgs e)
{
try
{
if (TotalItemCount >= 5)
{
if (TotalItemCount < 10)
{
int i = 6;
while (i <= TotalItemCount)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = true;
i++;
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = false;
}
}
}
else if (TotalItemCount >= 10)
{
int i = 6;
while (i <= 10)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = true;
i++;
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = false;
}
}
}
}
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Set Visible :" + oEx.Message);
}
}
protected void SetInVisible(object sender, EventArgs e)
{
try
{
if (TotalItemCount >= 5)
{
if (TotalItemCount < 10)
{
for (int i = 6; i <= TotalItemCount; i++)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = false;
}
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = true;
}
}
else if (TotalItemCount >= 10)
{
for (int i = 6; i <= 10; i++)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = false;
}
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = true;
}
}
}
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Set In Visible:" + oEx.Message);
}
}
private void SetNode(string Lnktext)
{
try
{
if (TotalItemCount >= 5)
{
if (TotalItemCount < 10)
{
int i = 6;
while (i <= TotalItemCount)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = true;
lnk = (LinkButton)PanelNumber.FindControl("LinkButton" + i.ToString());
if (Lnktext == lnk.Text)
lnk.CssClass = "prismimagelinkSelected";
else
lnk.CssClass = "prismimagelink";
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = false;
}
i++;
}
}
else if (TotalItemCount >= 10)
{
int i = 6;
while (i <= 10)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = true;
lnk = (LinkButton)PanelNumber.FindControl("LinkButton" + i.ToString());
if (Lnktext == lnk.Text)
lnk.CssClass = "prismimagelinkSelected";
else
lnk.CssClass = "prismimagelink";
i++;
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = false;
}
}
}
}
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Set Node :" + oEx.Message);
}
}
private void SetInNode(string Lnktext)
{
try
{
if (TotalItemCount >= 5)
{
if (TotalItemCount < 10)
{
for (int i = 6; i <= TotalItemCount; i++)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = false;
}
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = true;
lnk = (LinkButton)PanelNumber.FindControl("LinkButton" + j.ToString());
if (Lnktext == lnk.Text)
lnk.CssClass = "prismimagelinkSelected";
else
lnk.CssClass = "prismimagelink";
}
}
else if (TotalItemCount >= 10)
{
for (int i = 6; i <= 10; i++)
{
PanelNumber.FindControl("LinkButton" + i.ToString()).Visible = false;
}
for (int j = 1; j <= 5; j++)
{
PanelNumber.FindControl("LinkButton" + j.ToString()).Visible = true;
lnk = (LinkButton)PanelNumber.FindControl("LinkButton" + j.ToString());
if (Lnktext == lnk.Text)
lnk.CssClass = "prismimagelinkSelected";
else
lnk.CssClass = "prismimagelink";
}
}
}
else
{
for (int k = 1; k <= TotalItemCount; k++)
{
PanelNumber.FindControl("LinkButton" + k.ToString()).Visible = true;
lnk = (LinkButton)PanelNumber.FindControl("LinkButton" + k.ToString());
if (Lnktext == lnk.Text)
lnk.CssClass = "prismimagelinkSelected";
else
lnk.CssClass = "prismimagelink";
}
}
}
catch (Exception oEx)
{
HttpContext.Current.Response.Write("Set In Node :" + oEx.Message);
}
}
please help me ASAP.
THANKS IN ADVANCE.