This is a migrated thread and some comments may be shown as answers.

HTML LI element in ItemTemplate cause JSON failure

4 Answers 186 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Ngan Pham
Top achievements
Rank 1
Ngan Pham asked on 15 Aug 2008, 07:48 AM
I'm testing PanelBar (Q2 2008) in BlogEngine.NET, when I put <li> element into template the IE7 show a debug message (Firefox 3 is ok):

---------------------------
Windows Internet Explorer
---------------------------
Assertion Failed: Length of elements and json must be the same!

Break into debugger?
---------------------------
OK   Cancel  
---------------------------

My code:

                                    <telerik:RadPanelItem runat="server">
                                        <ItemTemplate>
                                            <li><blog:SearchBox ID="SearchBox1" runat="server"  /></li>
                                        </ItemTemplate>
                                    </telerik:RadPanelItem>

Ngan

4 Answers, 1 is accepted

Sort by
0
nbushnell
Top achievements
Rank 1
answered on 05 Feb 2009, 05:40 PM
I am using the Q3 version and i get the same error.

I have found that that if you add HTML tags into the panel bar template at run time (in my case via data bound items) i get this error. Adding text is not a problem.

Is there a way to work around this?
0
Kevin
Top achievements
Rank 2
answered on 05 Mar 2009, 11:20 AM
Guys,

I found this error when posting back and dynamically creating RadMenuItems. The problem I found was that I was creating a new instance of a RadMenuItem, and was then using it multiple times, e.g.
Private Sub LoadUserTasks()  
        Dim objDV As DataView = CType(sqlDSGetUserMenuTasks.Select(New DataSourceSelectArguments), DataView)  
        Dim menuItem As New Telerik.Web.UI.RadMenuItem()  
 
        RadMenu2.Items(1).Items.Clear()  
        Dim iCounter As Integer = 0  
        For Each drRow As DataRow In objDV.Table.Rows  
            menuItem.Text = drRow("MenuName").ToString()  
            menuItem.ToolTip = drRow("MenuDescription").ToString()  
            menuItem.Value = drRow("MenuID").ToString()  
            menuItem.PostBack = False 
            RadMenu2.Items(1).Items.Add(menuItem)  
        Next 
End Sub 
In this case, everytime there was more than one row, the app would crash on line 12 with the "Assertion Failed" error.

The solution is to take line 3, "Dim menuItem as New Telerik.Web.UI.RadMenuItem" and move it into the For Each loop. That way, a new object is created everytime, rather than re-using a pre-existing one.

Hope it helps...this problem was doing my nut in until I found the solution!

Kev.
0
nbushnell
Top achievements
Rank 1
answered on 05 Mar 2009, 04:55 PM
Thanks Kev, but i am databinding all my panel bar elements. And All is fine until i add HTML elements to the panel bar during the ItemDataBound event.

<telerik:RadPanelBar ID="rpToday" runat="server" Width="920" OnItemDataBound="rpToday_ItemDataBound1" 
                        EnableEmbeddedSkins="false" Skin="TodaysDA" AllowCollapseAllItems="True" CausesValidation="False" 
                        EnableAjaxSkinRendering="False" CollapseDelay="1" ExpandDelay="1" MaxDataBindDepth="3" 
                        EnableViewState="false" OnClientItemClicking="DAOnClientItemClicking"
                        <ItemTemplate> 
                            <asp:Panel ID="pnlItem" runat="server"
                                <uc2:BitDetail ID="BitDetail1" runat="server" BitCategories='<%# Eval("bitCategories") %>' 
                                    BitDescription='<%# Eval("bitDescription") %>' BitICue='<%# Eval("bitICue") %>' 
                                    BitOCue='<%# Eval("bitOCue") %>' BitLength='<%# Eval("bitLength") %>'
                                    BitID='<%# Eval("BitID") %>' Rating='<%# Eval("Rating") %>' /> 
                            </asp:Panel> 
                        </ItemTemplate> 
                        <CollapseAnimation Type="None" Duration="0"></CollapseAnimation> 
                        <ExpandAnimation Type="None" Duration="0"></ExpandAnimation> 
                    </telerik:RadPanelBar> 

then i handle the event.

 protected void rpToday_ItemDataBound1(object sender, Telerik.Web.UI.RadPanelBarEventArgs e) 
    { 
        Telerik.Web.UI.RadPanelItem r = (Telerik.Web.UI.RadPanelItem)e.Item; 
 
// snip: more processing 
 
        r.DataBind(); 
    } 

if bitDescription, for example, has  HTML tags in it I will get this JSON error. If i strip out all the HTML tags from bitDescriptionand run the same code i do not get the error.

0
Mohammed Imaduddin
Top achievements
Rank 1
answered on 07 Aug 2009, 09:16 PM
I am using 2009 Q2 version.

I had the same JSON error, but after carefully looking at my html code, I noticed that it was not well formed. I had a few <li> tags which were not properly enclosed in <ul> elements. Once I fixed that, my error went away.
Tags
PanelBar
Asked by
Ngan Pham
Top achievements
Rank 1
Answers by
nbushnell
Top achievements
Rank 1
Kevin
Top achievements
Rank 2
Mohammed Imaduddin
Top achievements
Rank 1
Share this question
or