Adding RadScriptManager in Control/CodeBehind

3 posts, 0 answers
  1. pev
    pev avatar
    10 posts
    Member since:
    Dec 2006

    Posted 30 Apr 2009 Link to this post


    I am trying to create my own Page class which all my pages will inherit from instead of System.Web.UI.Page. This is so that can add different controllers and do various settings on all pages through many different projects (I know about Master pages and I use that as well, but this is used between various projects).

    The problem is when I try to add the RadScriptManager via my own Page class, some of the RadAjaxPanels will not work and it is like the page is sometimes acting a bit strange. It seems that the panels that are added via codebehind/Control classes works like they should, but the ones added in ASPX pages does not work. I have tried adding the RadScriptManager in both Init and Load, both before and after base.methodName(). I have also tried both Add and AddAt(0) on this.Form.Controls.

    Is there any solution to adding the RadScriptManager in a .cs class/codebehind or are the controls dependent of it beging added (on top) in the ASPX page?

    I am using version 2009.1.422.20.

    Thank you.
  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 30 Apr 2009 Link to this post

    Hi pev,

    Normally adding the script manager during OnInit (make sure it is the first control in the form) should do the trick. Could you provide some more info when this fails? Ideally you could paste some code here.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. pev
    pev avatar
    10 posts
    Member since:
    Dec 2006

    Posted 05 May 2009 Link to this post

    I cannot post the whole page and controller here, but here is the setup we had:

    Our page class:
    public class MyPage : Page  
      override onInit()  
        Page.Form.Controls.AddAt(0, ScriptManager);  

    Then we inherited from this class instead of Page in our pages:
    public partial class _Default : MyPage  

    And our aspx page:
    <form id="form1" runat="server">  
    <Lib:MyAjaxLoadingPanel runat="server" ID="ajaxLoadingPanel1"></Lib:MyAjaxLoadingPanel> 
          <telerik:RadAjaxPanel ID="rapSeller" runat="server" LoadingPanelID="ajaxLoadingPanel1">  

    The setup was ike this but with a lot more complex pages and other controls. And whenever trying to add my Scriptmanager in the page class, the RadAjaxPanels would not work, the ones added in the ASPX atleast.

    We decided to add the Scriptmanager in a controller instead, and then we add this controller to every aspx page we have.

    Thanks for you help!
Back to Top