Adding A RadAjaxManager In A WebPart
This article on the Telerik site is actually not correct:
http://www.telerik.com/help/aspnet-ajax/ajax-ajxmanager-is-null-added-in-sharepoint-webpart.html
The problem with this is you will be modifying the control collection during an event when it can’t be modified. This will result in the error:
The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
If you attempt to move the addition to a different event, generally when using something like a
- RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
you will get an object reference error. The best way to do it is within the Init of the WebPart, and then capture the PreRender of the Page.
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
- Page.PreRender += Page_PreRender;
- }
- void Page_PreRender(object sender, EventArgs e)
- {
- RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(Page);
- if (ajaxManager == null)
- {
- RadAjaxManager manager = new RadAjaxManager();
- manager.ID = "RadAjaxManager1";
- Page.Items.Add(typeof(RadAjaxManager), manager);
- Page.Form.Controls.Add(manager);
- }
- }
Articles & Research
SharePoint Security
SharePoint Development
SharePoint Architecture
Claims Authentication
Forefront For SharePoint
AIS / Dynamics GP
Team Foundation Server
Pex And Moles
ISA/TMG/IAG/UAG
DPM
Cardspace
Research Methodology
Rural ICT Development
Numerical Analysis
Multi-Level Research
Knowledge Management
Personal/Off-Topic