15 Answers, 1 is accepted
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
Thank you
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
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.
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.
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)
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.
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
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.
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
Hopefully this will sort out my problem.
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().
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.