RadAjaxManager and Radscriptmanager in code behind

4 posts, 1 answers
  1. PeterVV
    PeterVV avatar
    7 posts
    Member since:
    Jul 2006

    Posted 05 Feb 2010 Link to this post

    Code below will fail because the RadAjaxManager won't be found (RadAjaxManager.GetCurrent returns null). The handler won't be added. However when I place the RadScriptManager component on the form in stead of creating it in the Code behind everything runs fine. (The RadAjaxManager is placed on the form)

    How can I make it in such a way that it will also work when creating the RadScriptManager in the codebehind

        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
     
            Dim _ScriptManager As RadScriptManager  
            _ScriptManager = New RadScriptManager  
            _ScriptManager.ID = "ScriptManager" 
            _ScriptManager.EnablePageMethods = True 
            Form.Controls.AddAt(0, _ScriptManager)  
     
            If RadAjaxManager.GetCurrent(Me.Page) IsNot Nothing Then 
                AddHandler RadAjaxManager.GetCurrent(Me.Page).AjaxRequest, AddressOf HandledRadAjaxRequest  
            End If 
     
        End Sub 
     


  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 10 Feb 2010 Link to this post

    Hello PeterVV,

    Please try creating the ScriptManager on Page_Init instead of on Page_Load and see if it makes any difference.

    Kind regards,
    Iana
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. PeterVV
    PeterVV avatar
    7 posts
    Member since:
    Jul 2006

    Posted 10 Feb 2010 Link to this post

    When creating the scriptmanager in the the Page_Init does not change this behavoir. The handler still won't be set because RadAjaxManager.GetCurrent returns nothing. Having a look at the (form) controls during runtime shows that the scriptmanager is the first control in the collection and the ajaxmanager the 3th one (in my example).

    Setting the handler somewhere else (Page_LoadComplete for example) doesn't change the behavoir. the handler won't be set.

    The Idea behind this is to create the scriptmanager object automatically in a 'BasePageClass' so there is no need anymore to add it on the (inherited) forms.
  4. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 12 Feb 2010 Link to this post

    Hi PeterVV,

    I followed your scenario and was able to replicate the problem. It seems that when the ScriptManager is created dynamically, you need to create the RadAjaxManager on Page_Init as well.
    I prepared a sample project illustrating the suggested solution.
    Please give it a try and let me know if it works for you.

    Kind regards,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top