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

Dynamically added Ribbon button throwing Sys.WebForms.PageRequestManagerServerErrorException

5 Answers 60 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Mohan
Top achievements
Rank 1
Mohan asked on 13 Jul 2011, 04:08 PM

Hi,

I am adding a new Ribbon tab with two ribbon buttons dynamically. When i click the added ribbon button, its throwing the error,
Error: Sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection.

What may be the Issue?

 

Thanks,
Mohan

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 18 Jul 2011, 11:31 AM
Hello Mohan,

RibbonBar items are not stored in ViewState, so you have to add them on each page load in the Init phase (Page.OnInit).

I hope this helps.

Regards,
Simon
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Hunter
Top achievements
Rank 1
answered on 27 Dec 2011, 10:58 PM
Hello guys,

I too ran into this same problem and have since moved my ribbon (re)creation to page_Init event (vb.net). Everything works as expected with one exception. My design implements dynamically loaded user controls which tell the containing page which ribbon configuration to use (ribbon is located in aspx page). In my initial testing I loaded the ribbon in the page_load event. In that event I was late enough in the page's life cycle to read a radTreeview's selected node value to retreive the settings required by the currently loaded user control. Now that I am forced to use the page_init event I obviously don't have access to the treeview. Could anyone suggest a way to store a value which can be read during page_init?
0
Bozhidar
Telerik team
answered on 28 Dec 2011, 11:24 AM
Hello Hunter,

To read a value in the Page_Init event, you can use a hidden field and the Request object. Please refer to this forum post for more information on the topic.

Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Hunter
Top achievements
Rank 1
answered on 28 Dec 2011, 05:07 PM
That did it! Thanks for the help!
0
Garry
Top achievements
Rank 2
Veteran
answered on 28 Mar 2012, 09:44 AM
Great tip about using Page_Init() event - solved my problem with dynamic and contextual ribbon tabs.
Tags
RibbonBar
Asked by
Mohan
Top achievements
Rank 1
Answers by
Simon
Telerik team
Hunter
Top achievements
Rank 1
Bozhidar
Telerik team
Garry
Top achievements
Rank 2
Veteran
Share this question
or