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

Disabling RadMenu EnableViewState does not work

1 Answer 20 Views
Menu
This is a migrated thread and some comments may be shown as answers.
tomekm
Top achievements
Rank 1
tomekm asked on 05 May 2011, 12:55 PM

I use RadMenu:

<telerik:RadMenu EnableSelection="true" Skin="" OnItemDataBound="SiteMenu_databound" EnableViewState="false"
ID="SiteMenu" DataSourceID="SiteMapDataSource" runat="server">
</telerik:RadMenu>

I tried to reduce my pages' size so I am disabling ViewState on controls. I tried disabling RadMenu's viewstate but it does not work

Here are viewstate size stats:

Control Id    Type    ViewState Size

ctl00$ctl00$ContentPlaceHolder1$SiteMenu Telerik.Web.UI.RadMenu 0
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i0 Telerik.Web.UI.RadMenuItem 300
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i1 Telerik.Web.UI.RadMenuItem 244
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i1$i0 Telerik.Web.UI.RadMenuItem 200
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i1$i1 Telerik.Web.UI.RadMenuItem 184
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i2 Telerik.Web.UI.RadMenuItem 244
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i2$i0 Telerik.Web.UI.RadMenuItem 228
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i2$i1 Telerik.Web.UI.RadMenuItem 180
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i2$i2 Telerik.Web.UI.RadMenuItem 208
ctl00$ctl00$ContentPlaceHolder1$SiteMenu$i2$i3 Telerik.Web.UI.RadMenuItem 188

You see that RadMenu viewstate is 0 but RadmenuItems not. Why is that?

1 Answer, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 10 May 2011, 09:18 AM
Hi Rychu,

It is very strange if the RadMenuItems persist the ViewState after you've disabled the ViewState of the control. That's why I've created a sample project to test this case.

In my project I am calculating the ViewState size of the page via additional classes. To check the issue please set at first load the EnableViewState property of the RadMenu to "true":

<telerik:RadMenu ID="RadMenu1" runat="server" EnableViewState="true">
        <Items>
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1" BackColor="Red" EnableViewState="false">
                <Items>
                    <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1" BackColor="Blue" EnableViewState="false">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 2" EnableViewState="false">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem2" Font-Bold="true" EnableViewState="false">
                <Items>
                    <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1" EnableViewState="false">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem3" EnableViewState="false">
            </telerik:RadMenuItem>
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem4" EnableViewState="false">
                <Items>
                    <telerik:RadMenuItem runat="server" Text="Child RadMenuItem 1" EnableViewState="false">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadMenuItem>
        </Items>
    </telerik:RadMenu>

On first load of the page you will see the size of the Page's ViewState. After that you can disable the ViewState of the control. No matter if you set the EnableViewState property of each RadMenuItem - the size of the ViewState will stay unchanged. That means that the separate Items doesn't persis ViewState.

Please find the full code in the attached .zip file and let me know if this was helpful.

Regards,
Veronica Milcheva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Menu
Asked by
tomekm
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Share this question
or