kamagra how much to take

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

  1.  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.

  1.         protected override void OnInit(EventArgs e)
  2.         {
  3.             base.OnInit(e);
  4.             Page.PreRender += Page_PreRender;
  5.          }
  6.  
  7.         void Page_PreRender(object sender, EventArgs e)
  8.         {
  9.             RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(Page);
  10.             if (ajaxManager == null)
  11.             {
  12.                 RadAjaxManager manager = new RadAjaxManager();
  13.                 manager.ID = "RadAjaxManager1";
  14.                 Page.Items.Add(typeof(RadAjaxManager), manager);
  15.                 Page.Form.Controls.Add(manager);
  16.             }
  17.         }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>