Only single Ajax Amanager per page?

16 posts, 0 answers
  1. Yuri
    Yuri avatar
    4 posts
    Member since:
    Oct 2005

    Posted 24 Apr 2007 Link to this post

    It seems that only one single instance of AjaxManager is allowed per page. What happens if I create a couple of user controls that incorporate AjaxManager? Is this is a bug or intentionally designed like this?

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 25 Apr 2007 Link to this post

    Hello Yuri,

    The new ajax manager is designed to work in similar to ScriptManager way. You can use GetCurrent() method to get the manager from the user controls.

    Kind regards,
    Vlad
    the telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Iurii
    Iurii avatar
    18 posts
    Member since:
    Oct 2006

    Posted 25 Apr 2007 Link to this post

    That helps :)

    Thank you
  5. Iurii
    Iurii avatar
    18 posts
    Member since:
    Oct 2006

    Posted 25 Apr 2007 Link to this post

    Thanks for the help. Everything works.  I also have noticed that i can use ajaxLoadingPanel on user controls, however in design time it is telling me that i need an instance of the scriptmanager.
  6. Leon
    Leon avatar
    373 posts
    Member since:
    Apr 2007

    Posted 26 Apr 2007 Link to this post

    Ramin,

    From migration steps article:

    http://www.telerik.com/help/radcontrols/prometheus/ajxMigration.html

    It seems that you must have the ScriptManager on each page using RadAjax Prometheus controls.

    Regards,
    Leon
  7. Shaun Peet
    Shaun Peet avatar
    571 posts
    Member since:
    Aug 2004

    Posted 26 Apr 2007 Link to this post

    Vlad,

    Can you provide a little more details about the GetCurrent() method; perhaps even a little example of how to use it.

    I'm trying to wrap my head around how to acheive this particular solution with the new AjaxManager:

    Master Page -> Default.aspx page.  The Default.aspx page dynamically loads user controls.  In one such case a single page contains two user controls in a shopping-cart type situation - where one user control displays products and the other user control shows the number of items in the cart.

    Using the old radAjax I would have an AjaxManager in each user contol.  The user control that displayed the products would use a callback to add the item to the cart, and then call some javascript within the cart user control that would trigger an AjaxManager.AjaxRequest() to update the number of items in the cart:

    <script language="javascript" type="text/javascript">  
     
        function clientCartUpdate()  
        {  
            var AjaxManager = <%= ramCartItmes.ClientID %>;  
            AjaxManager.AjaxRequest('UpdateItems');  
        }  
          
    </script> 


    Now, using the new r.a.d.Ajax I've plopped the AjaxManager and ScriptManager on the master page.  This means that I can't reference the AjaxManager using that same javascript function because it references the server-side AjaxManager that no longer exists within the user control.  So, in theory, I suppose I could move both the server-side code and client-side code to the master page; but that creates unneccesary script in the master page.  I'm thinking that the GetCurrent() method might do the trick; just not sure how to implement it.

    Thanks,

    Shaun.
  8. Iurii
    Iurii avatar
    18 posts
    Member since:
    Oct 2006

    Posted 26 Apr 2007 Link to this post

    Leon, I have read the documentation and I completely understand that I need script manager on each page. However, because you can have only one script manager per page, i can not include it in my user controls.

    Now, since i don't have scriptmanager in my usercontrol, any instance of ajaxloadingPanel errors out design time. Runtime everything works just fine.

    Let's see what Telerik support will say.
  9. surfer
    surfer avatar
    585 posts
    Member since:
    Jul 2003

    Posted 26 Apr 2007 Link to this post

    Looking at Reflector, GetCurrent is a public method of RadAjaxManager which retrieves the AjaxManager instance per page. The code is:

    public static RadAjaxManager GetCurrent(Page page)
    {
        if (page == null)
        {
            throw new ArgumentNullException("page");
        }
        return (page.Items[typeof(RadAjaxManager)] as RadAjaxManager);
    }

    if basically, checking Page.Items[typeof(RadAjaxManager)] will give you the instance of the AjaxManager (or null if no AjaxManager is available)
  10. Ken Fleming
    Ken Fleming avatar
    12 posts
    Member since:
    Apr 2007

    Posted 01 May 2007 Link to this post

    How does a C# method help in a javascript.
    I am getting the error Object doesn't support this method when I try to use AjaxRequest in a user control loaded onto the page in which the RadAjaxManager is declared.
  11. Ken Fleming
    Ken Fleming avatar
    12 posts
    Member since:
    Apr 2007

    Posted 01 May 2007 Link to this post

    Ok, GetAjaxEventReference worked in this particular instance, but I think the Prometheus Ajax needs better documentation.  I have not been able to get a javascript to work in a user control yet.
  12. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 02 May 2007 Link to this post

    Hello,

    You can get the ajax manger client-side object using $find("<%= RadAjaxManager1.ClientID %>").

    Best wishes,
    Vlad
    the telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 02 Aug 2007 Link to this post

    Hi,

    I am having this same problem with the Prometheus Ajax control.  My javascript gives me an error 'Object doesnt support this property or method' when trying to access the 'AjaxRequest' method of the AjaxManager.  I can access the AjaxManager, but cannot call the function.

    I also cannot use the suggested workaround of putting "<%= AjaxManager.ClientID %>" in my code as my page is almost entirely created dynamically and you cannot use code blocks in the aspx if you are dynamically adding controls.

    Can anyone suggest another workaround for this?  Its driving me mad because I cant understand why I can happily access my AjaxManager instance yet cannot call the AjaxRequest function with it?

    Any help massively appreciated.
  14. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 03 Aug 2007 Link to this post

    Hello Jonathan,

    I suggest you take advantage of the RadAjaxManagerProxy feature introduced in the latest version of RadAjax "Prometeus" to bypass the problem with the AjaxRequest event execution you are currently facing.

    For your convenience I have prepared a sample web site which loads user control dynamically on the main page. The main page wraps ScriptManager and RadAjaxManager instances while the user control encapsulates RadAjaxManagerProxy with settings adding programmatically on PageLoad. The result will be that a label's text will be updated with the selection made in the dropdown list control.

    Feel free to use the same technique when building controls programmatically in your project.

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  15. Jonathan
    Jonathan avatar
    92 posts
    Member since:
    Feb 2007

    Posted 03 Aug 2007 Link to this post

    Thanks for the reply and the attached code which I will try out.  I had noticed the RadAjaxManagerProxy but didnt realise this could help me out. 

    Hopefully this will sort out my problem.
  16. MB
    MB avatar
    149 posts
    Member since:
    Jan 2005

    Posted 12 Aug 2007 Link to this post

    I'm afraid that I'm a complete idiot, as I STILL don't understand how the server-side events work with the RadAjaxManager and RadAjaxManagerProxy.

    Although the sample above doesn't actually use the Masterpage, I assume that if using a MasterPage you insert the RadAjaxManager on the MasterPage, similar to the way you insert a single ScriptManager, and then use the RadAjaxManagerProxy on child Pages & Controls

    However... who and what handles the AjaxRequest() events, and where ??

    I am trying to build an example for myself, so I can come to grips with how this all works, and I decided to build something similar to:
    http://www.telerik.com/community/code-library/submission/b311D-hbagd.aspx 

    However, I want to place the grid and all the behind code on a UserControl, which is then placed onto a Page, which is then placed onto a MasterPage, as this better emulates my site.

    I assume that I would place the ScriptManager and RadAjaxManager on the Masterpage ??

    I then assume I would need a ScriptManagerProxy and RadAjaxManagerProxy on the UserControl.

    .. and then... the AjaxRequest delegate goes... where??  and is applied to what ??

    Sorry for sounding like such a dummy, but I don't seem to be able to conceptualize the single RadAjaxManager and how that works when multiple controls and/or pages might be making AjaxRequests().
  17. MB
    MB avatar
    149 posts
    Member since:
    Jan 2005

    Posted 13 Aug 2007 Link to this post

    Ok... I think that the penny has partially dropped for me, and I've worked this out, to some extent.

    It's a bit clunky, but I managed to deal with it by adding specific delegates to the single AjaxManager from within the UserControl that I want to handle a specific AjaxRequest event, at the UserControl level.

    Something like:

    public partial class MyControl : System.Web.UI.UserControl  
    {  
      protected void Page_Init(object sender, EventArgs e)  
      {  
        ...bla bla bla...  
     
        Telerik.Web.UI.RadAjaxManager RadAjaxManager1 = (Telerik.Web.UI.RadAjaxManager) this.Page.Master.FindControl("RadAjaxManager1");  
     
        RadAjaxManager1.AjaxRequest += new Telerik.Web.UI.RadAjaxControl.AjaxRequestDelegate(this.RadAjaxManager1_MyControlLevelAjaxRequest);  
     
        ...bla bla bla...  
      }  
     
     
      protected void RadAjaxManager1_MyControlLevelAjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)  
      {  
        ...bla bla bla...  
      }  

    I still seem to require the standard delegate at the MasterPage level, even if it does nothing.

    Although I haven't tested it, I assume that any other delegate I add at other pages and UserControls would also fire for any AjaxRequest fired from the Client... so I would need to test each event and exit.

    I'm still not sure if this is the "right" solution, but it does work. However, it's a bit on the clunky side, and being able to target specific delegates would obviously be better, so I'm sure that I'm still missing a basic point here.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017