Custom widget throwing js error
Hello,
I have created a custom widget for a side navigation that loads pages from a RadSiteMapDataSource .
The control loads and works apparently fine, but firebug shows a js error : f is not a costructor in Telerik.Web.UI.WebResource.axd line 20 and when i add another control on the same page, the new added control doesn't work when I click any tab .
The strange thing is that when I add another custom radpanelbar on the page all controls work .
This is the control that throws the error
SubNavigation.ascx
01.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SubNavigation.ascx.cs"
02.
Inherits="SitefinityWebApp.UserControls.SubNavigation" %>
03.
04.
<
telerik:RadPanelBar
runat
=
"server"
ID
=
"RadPanelBar1"
05.
06.
DataSourceID
=
"RadSiteMapDataSource2"
ExpandMode
=
"SingleExpandedItem"
CssClass
=
"subNav"
07.
onitemdatabound
=
"RadPanelBar1_ItemDataBound"
>
08.
09.
</
telerik:RadPanelBar
>
10.
<
telerik:RadSiteMapDataSource
ID
=
"RadSiteMapDataSource2"
runat
=
"server"
StartingNodeUrl
=
"~/products"
11.
ShowStartingNode
=
"false"
/>
01.
public
partial
class
SubNavigation : System.Web.UI.UserControl
02.
03.
public
String StartNode
get
;
set
;
04.
05.
protected
void
Page_Load(
object
sender, System.EventArgs e)
06.
07.
08.
if
(!StartNode.IsNullOrEmpty())
09.
10.
//SiteMapNode startNode =SiteMapBase.GetCurrentProvider().Fin
11.
RadSiteMapDataSource2.StartingNodeUrl =
"~/"
+ StartNode;
12.
13.
14.
protected
void
RadPanelBar1_ItemDataBound(
object
sender, RadPanelBarEventArgs e)
15.
16.
SiteMapNode currentNode = SiteMapBase.GetCurrentProvider().CurrentNode;
17.
RadPanelItem it = e.Item;
18.
19.
if
(it.Text.ToLower().Equals(currentNode.Title.ToLower()))
20.
21.
e.Item.ExpandParentItems();
22.
e.Item.CssClass =
" rpExpanded"
;
23.
e.Item.SelectedCssClass =
" rpExpanded"
;
24.
e.Item.ExpandedCssClass =
" rpExpanded"
;
25.
26.
27.
01.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Pdet.ascx.cs" Inherits="SitefinityWebApp.UserControls.Pdet" %>
02.
<
div
class
=
"tabsHolder"
>
03.
<
telerik:RadTabStrip
runat
=
"server"
ID
=
"RadTabStrip1"
Orientation
=
"HorizontalTop"
04.
CssClass
=
"tabsMenu"
Skin
=
"Athena"
EnableEmbeddedSkins
=
"false"
SelectedIndex
=
"0"
05.
MultiPageID
=
"RadMultiPage1"
>
06.
</
telerik:RadTabStrip
>
07.
<
telerik:RadMultiPage
runat
=
"server"
ID
=
"RadMultiPage1"
SelectedIndex
=
"0"
CssClass
=
"tabsPanes"
>
08.
</
telerik:RadMultiPage
>
09.
</
div
>
01.
public
partial
class
Pdet : System.Web.UI.UserControl
02.
03.
public
String ProductList
get
;
set
;
04.
05.
protected
void
Page_Load(
object
sender, EventArgs e)
06.
07.
if
(ProductList.IsNullOrEmpty())
08.
09.
ProductList =
this
.Page.Title;
10.
11.
else
12.
13.
var lists = App.WorkWith().Lists().Get().Where(li => li.Title.Equals(ProductList)).First();
14.
int
i = 1;
15.
foreach
(var listItem
in
((Telerik.Sitefinity.Lists.Model.List)lists).ListItems.Distinct())
16.
17.
if
(RadTabStrip1.Tabs.FindTabByText(listItem.Title.ToString()) ==
null
)
18.
19.
RadTab tab =
new
RadTab();
20.
tab.Text = listItem.Title;
21.
//tab.Text = listItem.Title + " " + RadTabStripTab.Tabs.Count;
22.
RadTabStrip1.Tabs.Add(tab);
23.
Literal listContent =
new
Literal();
24.
listContent.Text = listItem.Content;
25.
26.
27.
RadPageView page =
new
RadPageView();
28.
page.CssClass =
"tabPane"
;
29.
page.ID =
"RadPageView"
+ i++;
30.
page.Controls.Add(listContent);
31.
RadMultiPage1.PageViews.Add(page);
32.
33.
34.
35.
36.
Hi Tudor,
I can`t get your controls to work. I made small changes to them as described in documentation . And all worked fine. Tell me if this changes suit your purpose.
Modified your .ascx file like:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SubNavigation.ascx.cs" Inherits="SitefinityWebApp.SubNavigation.SubNavigation" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:SiteMapDataSource
ID
=
"RadSiteMapDataSource2"
runat
=
"server"
/>
<
sf:RadPanelBar
runat
=
"server"
ID
=
"RadPanelBar1"
DataSourceID
=
"RadSiteMapDataSource2"
ExpandMode
=
"SingleExpandedItem"
CssClass
=
"subNav"
onitemdatabound
=
"RadPanelBar1_ItemDataBound"
>
</
sf:RadPanelBar
>