This is a migrated thread and some comments may be shown as answers.
Issue with PanelBar control
1 Answer 39 Views
This is a migrated thread and some comments may be shown as answers.
Sabry Guen
Top achievements
Rank 1
Sabry Guen asked on 01 Jul 2009, 10:00 AM
 
I have an issue adding a user control to the RadPanelBar (ajax) Q3 2008 version.

My markup is as follows:

 <div style="margin-left: 20px;">
        <telerik:RadPanelBar ID="ParameterPanels" ExpandMode="MultipleExpandedItems" runat="server" Skin="Web20" Width="95%">
            <Items>
                <telerik:RadPanelItem runat="server">  
                </telerik:RadPanelItem>
            </Items>
        </telerik:RadPanelBar>
    </div>

In the code behind, I have the following code

                    foreach(ParameterControl aParameterControl in parameterControls)
                    {
                        // Load the parameter controls dynamically as long as we don't
                        // find a static value or data field parameter control
                        if(aParameterControl.ParameterControlID != 2 &&
                           aParameterControl.ParameterControlID != 29)
                        {
                                RadPanelItem panelItem = new RadPanelItem(aParameterControl.ParameterControlDescription);

                                Control c = Page.LoadControl(aParameterControl.ControlPath);

                                panelItem.Controls.Add(c);
                                ParameterPanels.Items.Add(panelItem);
                            }
                        }
                    }

and I end up with the following stacktrace

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.UI.ControlItem.get_Index() +31
Telerik.Web.UI.RadPanelItem.get_IsFirstVisibleItem() +27
Telerik.Web.UI.RadPanelItem.DetermineCssClass() +37
Telerik.Web.UI.RadPanelItem.AddAttributesToRender(HtmlTextWriter writer) +39
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +36
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
Telerik.Web.UI.RadPanelBar.RenderItems(HtmlTextWriter writer) +142
Telerik.Web.UI.RadPanelBar.RenderContents(HtmlTextWriter writer) +140
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +43
Telerik.Web.UI.RadDataBoundControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +98
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +43
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +336
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +56
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +234
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Page.Render(HtmlTextWriter writer) +39
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +596
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +129
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +53
System.Web.UI.Control.Render(HtmlTextWriter writer) +31
System.Web.UI.Page.Render(HtmlTextWriter writer) +39
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +74
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +291
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5428


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


further info:

Interestingly, if I change my markup to look like this, I don't get the error (I removed the first radPanelItem in the radPanelBar items collection)

 <div style="margin-left: 20px;">
        <telerik:RadPanelBar ID="ParameterPanels" ExpandMode="MultipleExpandedItems" runat="server" Skin="Web20" Width="95%">
        </telerik:RadPanelBar>
</div>

I would have thought that the control wouldn't be sensitive to an empty RadPanelItem but it obviously is. I would suggest that a null check is placed in the source for the next release around if that is the root of the issue.

Telerik.Web.UI.ControlItem.get_Index() +31
Telerik.Web.UI.RadPanelItem.get_IsFirstVisibleItem() +27

Thanks,

Sabry




1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 01 Jul 2009, 02:34 PM
Hi Sabry Guen,

I have reproduced the scenario using your very code, however there is no such a problem. In general, RadPanelBar should be able to handle such a scenarios. Most probably, it is something in your user control that is breaking the PanelBar. Have you tried to debug your application to see where the error is thrown?

You can find my test project as an attachment.

Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Asked by
Sabry Guen
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or