We have a RadWindowManager on a Page. We open RadWindows using Javascript
Everything works fine.
When I dynamically add a RadRotator to my page using the code below the RadWindow Script stops working. Instead of opening a window the page does a postback.
When i disable the handler, the script works again.
Below the handler code:
Can anyone help me to solve this problem? Why does the page perform a postback after adding the Rotator handler.
var oManager = GetRadWindowManager();
oManager.open(
"./Popup.aspx"
,
"Popup"
);
Everything works fine.
When I dynamically add a RadRotator to my page using the code below the RadWindow Script stops working. Instead of opening a window the page does a postback.
radRotator.ID =
"twitter"
+ ContentItem.ContentItemId;
radRotator.CssClass =
"RSSFountainClass"
;
radRotator.RotatorType =(TwitterRotatorType>0) ? TwitterRotatorType : RotatorType.AutomaticAdvance;
radRotator.ScrollDirection = RotatorScrollDirection.Up;
radRotator.ScrollDuration = ScrollDuration;
radRotator.FrameDuration = FrameDuration;
radRotator.ItemTemplate =
new
RotatorItemTemplate(ContentItem, RSSItemTemplateClass, RSSItemDateTimeClass, RSSItemDateClass, RSSItemTimeClass, RSSItemTitleClass);
radRotator.Height =
new
Unit(Height, UnitType.Pixel);
radRotator.DataSource = RSSDataSource();
radRotator.InitialItemIndex = -1;
radRotator.DataBind();
Controls.Add(radRotator);
When i disable the handler, the script works again.
Below the handler code:
private
class
RotatorItemTemplate : ITemplate
{
Label literal;
private
ContentItem ContentItem {
get
;
set
; }
private
string
RSSItemTemplateClass {
get
;
set
; }
private
string
RSSItemDateTimeClass {
get
;
set
; }
private
string
RSSItemDateClass {
get
;
set
; }
private
string
RSSItemTimeClass {
get
;
set
; }
private
string
RSSItemTitleClass {
get
;
set
; }
public
RotatorItemTemplate(ContentItem contentItem,
string
rssItemTemplateClass,
string
rssItemDateTimeClass,
string
rssItemDateClass,
string
rssItemTimeClass,
string
rssItemTitleClass)
{
literal =
new
Label();
ContentItem = contentItem;
RSSItemTemplateClass = rssItemTemplateClass;
RSSItemDateTimeClass = rssItemDateTimeClass;
RSSItemDateClass = rssItemDateClass;
RSSItemTimeClass = rssItemTimeClass;
RSSItemTitleClass = rssItemTitleClass;
}
public
void
InstantiateIn(Control container)
{
literal =
new
Label();
literal.DataBinding += TwitterItem_ItemDataBound;
container.Controls.Add(literal);
}
/// <summary>
/// TwitterItem_ItemDataBound Method
/// </summary>
/// <param name="sender">An object</param>
/// <param name="e">An EventArgs</param>
/// <returns>A void</returns>
private
void
TwitterItem_ItemDataBound(
object
sender, EventArgs e)
{
Label labelControl = (Label)sender;
RadRotatorItem rotatorItem = (RadRotatorItem)labelControl.NamingContainer;
XPathNavigator xPathNavigator = ((IXPathNavigable)rotatorItem.DataItem).CreateNavigator();
HtmlGenericControl htmlGenericControlItem =
new
HtmlGenericControl();
htmlGenericControlItem.Attributes.Add(
"onclick"
,
"window.open('"
+
((ContentItem.FileTitle == TwitterType.Follow.ToString())
? xPathNavigator.SelectSingleNode(
"link"
).Value
: xPathNavigator.SelectSingleNode(
"link/@href"
).Value)
+
"', '_blank')"
);
if
(!
string
.IsNullOrEmpty(RSSItemTemplateClass))
htmlGenericControlItem.Attributes.Add(
"class"
, RSSItemTemplateClass);
HtmlGenericControl htmlGenericControlDateTime =
new
HtmlGenericControl();
if
(!
string
.IsNullOrEmpty(RSSItemDateTimeClass))
htmlGenericControlDateTime.Attributes.Add(
"class"
, RSSItemDateTimeClass);
HtmlGenericControl htmlGenericControlTime =
new
HtmlGenericControl();
if
(!
string
.IsNullOrEmpty(RSSItemTimeClass))
htmlGenericControlTime.Attributes.Add(
"class"
, RSSItemTimeClass);
htmlGenericControlTime.Controls.Add(
new
LiteralControl(
((ContentItem.FileTitle == TwitterType.Follow.ToString())
? Convert.ToDateTime(xPathNavigator.SelectSingleNode(
"pubDate"
).Value).ToShortDateString()
: xPathNavigator.SelectSingleNode(
"author/name"
).Value))
);
HtmlGenericControl htmlGenericControlDate =
new
HtmlGenericControl();
if
(!
string
.IsNullOrEmpty(RSSItemDateClass))
htmlGenericControlDate.Attributes.Add(
"class"
, RSSItemDateClass);
htmlGenericControlDate.Controls.Add(
new
LiteralControl(
((ContentItem.FileTitle == TwitterType.Follow.ToString())
? Convert.ToDateTime(xPathNavigator.SelectSingleNode(
"pubDate"
).Value).ToShortTimeString()
: xPathNavigator.SelectSingleNode(
"updated"
).Value))
);
htmlGenericControlDateTime.Controls.Add(htmlGenericControlDate);
htmlGenericControlDateTime.Controls.Add(htmlGenericControlTime);
htmlGenericControlItem.Controls.Add(htmlGenericControlDateTime);
HtmlGenericControl htmlGenericControlTitle =
new
HtmlGenericControl();
if
(!
string
.IsNullOrEmpty(RSSItemTitleClass))
htmlGenericControlTitle.Attributes.Add(
"class"
, RSSItemTitleClass);
htmlGenericControlTitle.Controls.Add(
new
LiteralControl(
((ContentItem.FileTitle == TwitterType.Follow.ToString())
? xPathNavigator.SelectSingleNode(
"title"
).Value
: xPathNavigator.SelectSingleNode(
"content"
).Value)));
htmlGenericControlItem.Controls.Add(htmlGenericControlTitle);
labelControl.Controls.Add(htmlGenericControlItem);
}
}
Can anyone help me to solve this problem? Why does the page perform a postback after adding the Rotator handler.