protected void Page_Init(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
AddPageView(tabstripPersoneel.FindTabByText("Personeelsfiche"));
}
}
protected void Sidebar_TabClick(object sender, RadTabStripEventArgs e)
{
AddPageView(e.Tab);
e.Tab.PageView.Selected = true; //NullReferenceException happens Here
}
private void AddPageView(RadTab tab)
{
RadPageView pageView = new RadPageView();
pageView.ID = tab.Text;
ContentMultiPage.PageViews.Add(pageView);
tab.PageViewID = pageView.ID;
}
protected void ContentMultiPage_OnPageViewCreated(object sender, RadMultiPageEventArgs e)
{
string userControlName ="/Controls/"+ e.PageView.ID + "Weergave.ascx";
Control userControl = Page.LoadControl(userControlName);
userControl.ID = e.PageView.ID + "_userControl";
e.PageView.Controls.Add(userControl);
}
I have 3 radstrips which call the Sidebar_Tabclick method, each nested in a different pageview in a multipage. The sidebar looks like this:
<
telerik:RadMultiPage
runat
=
"server"
ID
=
"SideMultiPage"
SelectedIndex
=
"0"
>
<
telerik:RadPageView
runat
=
"server"
ID
=
"PageviewPersoneelsleden"
>
<
telerik:RadTabStrip
ID
=
"tabstripPersoneel"
runat
=
"server"
Orientation
=
"VerticalLeft"
OnClientTabSelecting
=
"onTabSelecting"
OnTabClick
=
"Sidebar_TabClick"
>
<
Tabs
>
<
telerik:RadTab
Text
=
"Personeelsfiche"
runat
=
"server"
Selected
=
"True"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Arbeidsovereenkomst"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Asset"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Certificaten"
PageViewID
=
"Certificaat"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Ervaringen"
PageViewID
=
"Ervaring"
runat
=
"server"
>
</
telerik:RadTab
>
</
Tabs
>
</
telerik:RadTabStrip
>
</
telerik:RadPageView
>
<
telerik:RadPageView
ID
=
"PageviewAfwezigheden"
runat
=
"server"
>
<
telerik:RadTabStrip
ID
=
"tabstripAfwezigheden"
runat
=
"server"
Orientation
=
"VerticalLeft"
OnTabClick
=
"Sidebar_TabClick"
>
<
Tabs
>
<
telerik:RadTab
Text
=
"Afwezigheid inplannen"
PageViewID
=
"Afwezigheid"
runat
=
"server"
Selected
=
"True"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Maandoverzicht afwezigheden"
PageViewID
=
"Maandoverzicht"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Jaaroverzicht afwezigheden"
PageViewID
=
"Jaaroverzicht"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Kalenderoverzicht"
PageViewID
=
"Kalender"
runat
=
"server"
>
</
telerik:RadTab
>
</
Tabs
>
</
telerik:RadTabStrip
>
</
telerik:RadPageView
>
<
telerik:RadPageView
ID
=
"PageviewWagens"
runat
=
"server"
>
<
telerik:RadTabStrip
ID
=
"TabstripWagens"
runat
=
"server"
Orientation
=
"VerticalLeft"
OnTabClick
=
"Sidebar_TabClick"
>
<
Tabs
>
<
telerik:RadTab
Text
=
"Wagens"
PageViewID
=
"Wagen"
runat
=
"server"
Selected
=
"True"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Tankkaarten"
PageViewID
=
"Tankkaart"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Technische onderhouden"
PageViewID
=
"Onderhoud"
runat
=
"server"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Expertiseverslagen"
PageViewID
=
"Expertiseverslag"
runat
=
"server"
>
</
telerik:RadTab
>
</
Tabs
>
</
telerik:RadTabStrip
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
Each tab corresponds to a different custom control. the intent is to copy the workings of http://demos.telerik.com/aspnet-ajax/tabstrip/examples/multipage/dynamic-pageview-creation/defaultcs.aspx. When I execute this, the first pageview loads fine, but when I try to load the second one, it gives me a nullreferenceException on the line with the comment at the end. It seems like it doesn't assign Pageview a value.