+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / RadAjaxPanel in custom control

RadAjaxPanel in custom control

8 posts, 0 answered
  1. mattc
    mattc avatar
    105 posts
    Registered:
    11 Aug 2007
    12 Nov 2009
    Link to this post
    Hi all

    Just trying to Ajaxify a custom control. Got a script manager in the master file and if I add a RadAjaxPanel to the embedded template in the custom control it all works fine....

    Only problem is in the Sitefinity editor, it displays ok when I click on the page, but when I click edit page that control displays an "Error Rendering Control - Object reference not set to an instance of an object" Take the  AjaxPanel out and it works fine...

    Some difference in the way Sitefinity loads the control when in edit mode?

    Matt
  2. Mr. Plinko
    Mr. Plinko avatar
    13 posts
    Registered:
    16 Jul 2009
    12 Nov 2009
    Link to this post
    This is an error I use to get when I was trying to add RadControls to my pages without identifying them in the web.config. Perhaps you can try adding to the web.config:

    <add name="RadAjaxPanel"  
         section="RadControls"  
         type="Telerik.Web.UI.RadAjaxPanel, Telerik.Web.UI" />  

    where the other RadControls are listed (such as the RadMenu).
  3. mattc
    mattc avatar
    105 posts
    Registered:
    11 Aug 2007
    13 Nov 2009
    Link to this post
    Hello

    Good point, I added it to web.config but that didn't solve it..

    The control works in the site and even in the manager, only breaks when I have the page in edit mode..

    Matt
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2009
    Link to this post
    Hello mattc,

    In edit mode the page is null and control cannot be rendered correctly. You can just disable the preview mode in edit mode to remove the error message. This will not break control functionality. Sample code:

    protected override void CreateChildControls()
           {
               if (Page == null || DesignMode)
               {
                   Label eLabel = new Label();
                   eLabel .Text = "control does not support design mode";
                   this.Controls.Add(eLabel);
               }
               else
               {
     
                   base.CreateChildControls();
               }
     
           }

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. mattc
    mattc avatar
    105 posts
    Registered:
    11 Aug 2007
    18 Nov 2009
    Link to this post
    Hi Ivan

    ah ok.
    The control I'm working on inherits Telerik.Cms.Web.UI.SimpleControl and uses an embedded template.

    I saw an article a while ago about this I think. Do I have to override the Render method or similar? Think that was based on GenericControl though? Can't find the article again now though.

    Thanks

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Nov 2009
    Link to this post
    Hello mattc,

    Overriding CreateChildControls() should do the trick here.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. mattc
    mattc avatar
    105 posts
    Registered:
    11 Aug 2007
    18 Nov 2009
    Link to this post
    Hi Ivan

    That works great!

    Thanks
  8. sandip
    sandip avatar
    1 posts
    Registered:
    18 Jun 2011
    02 Aug 2011
    Link to this post
    Hi,

    I have faced same problem.

    Can you plz share your working project here?

    Thanx in advance.

    Sandip.
Register for webinar
8 posts, 0 answered