Hi,
I have a solution that adds tabs and page views dynamically, then based on postback criteria may potentially remove those tabs and add new ones.
The sequence is:
- First Render:
- Build Tab with PageViewID set
- Build PageView using known PageViewID
- Add control to PageView
- Add PageView to MultiPageView
- Postback (no changes of tab):
- Find PageView and Add Control
(all working fine so far no matter how many postbacks)
- Postback (changes to tabs):
- Find PageView
- Find Tab
- Remove Tab
- Remove PageView
- Perform sequence as per First Render except with different Tab and PageView
Then during this postback there is some code changing tab selection. This code sets this.{Tab}.Selected = true;
An exception is thrown at this point from the Telerik libraries.
System.NullReferenceException occurred
Message=Object reference not set to an instance of an object.
Source=Telerik.Web.UI
StackTrace:
at Telerik.Web.UI.ControlItem.get_Index()
at Telerik.Web.UI.RadTab.set_Selected(Boolean value)
I have tried when adding +/ removing to change the SelectIndex of the RadTabStrip. I have tried selecting another (known to exist) tab. some general stuff like:
Nothing I have tried is preventing this exception. I have not seen any demo or example of adding then removing + adding during page life cycles.
The other question I have is why do the RadTabStrip and MultiPageView recreate the dynamic tabs. This is not like normal ASP.NET controls which you must recreate every postback in the same order. Is there a way to prevent automatic recreation of tabs?
Thanks.
I have a solution that adds tabs and page views dynamically, then based on postback criteria may potentially remove those tabs and add new ones.
The sequence is:
- First Render:
- Build Tab with PageViewID set
- Build PageView using known PageViewID
- Add control to PageView
- Add PageView to MultiPageView
- Postback (no changes of tab):
- Find PageView and Add Control
(all working fine so far no matter how many postbacks)
- Postback (changes to tabs):
- Find PageView
- Find Tab
- Remove Tab
- Remove PageView
- Perform sequence as per First Render except with different Tab and PageView
Then during this postback there is some code changing tab selection. This code sets this.{Tab}.Selected = true;
An exception is thrown at this point from the Telerik libraries.
System.NullReferenceException occurred
Message=Object reference not set to an instance of an object.
Source=Telerik.Web.UI
StackTrace:
at Telerik.Web.UI.ControlItem.get_Index()
at Telerik.Web.UI.RadTab.set_Selected(Boolean value)
I have tried when adding +/ removing to change the SelectIndex of the RadTabStrip. I have tried selecting another (known to exist) tab. some general stuff like:
if
(tabStrip.Tabs.Count > 1)
{
tabStrip.Tabs[0].Selected = true;
tabStrip.Tabs[0].PageView.Selected = true;
}
Nothing I have tried is preventing this exception. I have not seen any demo or example of adding then removing + adding during page life cycles.
The other question I have is why do the RadTabStrip and MultiPageView recreate the dynamic tabs. This is not like normal ASP.NET controls which you must recreate every postback in the same order. Is there a way to prevent automatic recreation of tabs?
Thanks.