Hi,
I have a page containing a ribbon bar and a content control (div).
I added AjaxSettings for this (in CreateChildControls):
The control for the content div is dynamically created (dependent on the button I clicked in the ribbon bar).
So far, this works. While the control is dynamically loaded and added to the content div, the content div shows the loading panel.
Now I built a control containing a radgrid and a button for testing purposes:
The loading panel is the same as the one from the main page (if I don't use a loading panel here, I get the error too).
When the control is dynamically created the first time, everything is ok. The div shows the loading panel until the control is ready. When I click the button, m_radGrid.Rebind() is called and the RadGrid shows a loading panel.
But when another dynamically created control is added to the content div (I call m_contentPanel.Clear() first), I get a loading panel and this exception (right after I added the grid to the ajaxsettings):
Exception type: InvalidOperationException
Exception message: Collection was modified; enumeration operation may not execute
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
at Telerik.Web.UI.RadAjaxControl.OnPagePreRender(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
What is the correct way to add dynamically created controls to the AjaxSettings so that my case will work?
Thanks!
I have a page containing a ribbon bar and a content control (div).
I added AjaxSettings for this (in CreateChildControls):
AjaxSetting ajaxSetting1 =
new
AjaxSetting(m_ribbonBar.ID);
ajaxSetting1.UpdatedControls.Add(
new
AjaxUpdatedControl(m_contentPanel.ID, m_loadingPanel.ID) { UpdatePanelHeight =
new
Unit(
"100%"
) });
RadAjaxManager1.AjaxSettings.Add(ajaxSetting1);
The control for the content div is dynamically created (dependent on the button I clicked in the ribbon bar).
So far, this works. While the control is dynamically loaded and added to the content div, the content div shows the loading panel.
Now I built a control containing a radgrid and a button for testing purposes:
protected
override
void
CreateChildControls()
{
base
.CreateChildControls();
Button b =
new
Button();
b.ID =
"B"
;
b.Text =
"Search again"
;
b.Click +=
new
EventHandler(b_Click);
Controls.Add(b);
m_grid =
new
RadGrid();
m_grid.ID =
"Grid"
;
m_grid.NeedDataSource += (grid_NeedDataSource);
m_grid.AllowPaging =
true
;
m_grid.PageSize = 10;
Controls.Add(m_grid);
RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(b, m_grid, LoadingPanel);
RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(m_grid, m_grid, LoadingPanel);
}
The loading panel is the same as the one from the main page (if I don't use a loading panel here, I get the error too).
When the control is dynamically created the first time, everything is ok. The div shows the loading panel until the control is ready. When I click the button, m_radGrid.Rebind() is called and the RadGrid shows a loading panel.
But when another dynamically created control is added to the content div (I call m_contentPanel.Clear() first), I get a loading panel and this exception (right after I added the grid to the ajaxsettings):
Exception type: InvalidOperationException
Exception message: Collection was modified; enumeration operation may not execute
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
at Telerik.Web.UI.RadAjaxControl.OnPagePreRender(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
What is the correct way to add dynamically created controls to the AjaxSettings so that my case will work?
Thanks!