11 Answers, 1 is accepted
Find more information about loading User controls with RadAjax in the following articles:
RadAjax and WebUserControls
Load user controls
Loading User Controls-Demo
All the best,
Pavlina
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
I have a user control with a textbox, a couple buttons, and a label. Enter text, click a button, the label is set.
The usercontrol is structured as follows:
<RadAjaxPanel>....my controls...</RadAjaxPanel>
So I expected that each user control would operate autonomously from whatever parent page makes use of them.
A simple page has a RadScriptManager and with nothing but the same usercontrol added a few times with public properties set to invoke different behavior. It looks like initializers are firing for all instances of the usercontrol whenever an event is fired on any of them. When the entire page is submitted then I'll extract data from all controls, but until then there should be no link between these controls.
What am I missing?
Thanks!
From the information provided so far I am not able to determine the exact source of the issue you are facing. At this point I will ask you to open a formal support ticket and send us a small runnable application. Thus I could do all my best to find a quick resolution of this matter.
Sincerely yours,
Pavlina
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.
I understand that lack of information makes it impossible to answer many questions. Perhaps the answer to this general question will help: What's the proper pattern for putting multiple instances of a given user control onto a Rad-enabled form?
Here is what I have for two controls exhibiting the same behaviour:
Form.aspx:
<html>...<RadScriptManager/><uc1:mycontrol1/><uc2:mycontrol2/></html>
MyControl.ascx:
<div><RadAjaxPanel>...controls...</RadAjaxPanel></div>
When an event is fired on any instance of the control, all of the instances re-initalize on the server, and then the event is fired on the specific instance. It looks like any event creates a postback for all controls.
In the LoadUserControls example, there is no RadAjaxPanel in the usercontrol. I just wanted to make sure my control is Ajax-aware so that I didn't need to manage ajaxification in the container. Is that overkill?
Thanks again.
Form.aspx:
<html>...<RadScriptManager/><RadAjaxManager/>
<asp:Panel ID="Panel1"><uc1:mycontrol ID="c1"/></asp:Panel>
<asp:Panel ID="Panel2"><uc1:mycontrol ID="c2"/></asp:Panel>
</html>
MyControl.ascx:
...nothing but controls...
Then use the RadAjaxManager to have Panel1 update Panel1, Panel2 update Panel2, etc.
My problem related to this is fixed. Now I can move on to diagnosing other weird behaviours. :)
Thanks.
I suggest that you try to replace RadAjaxPanel which you use inside a WebUserControl with RadAjaxManagerProxy control and configure it in the same way as the AjaxPanel to AJAX-enable the user control completely.
Note that we highly recommend avoid working with the RadAjaxManager and RadAjaxPanel controls at the same time.
Please give this suggestion a try and let me know how it goes and if any other questions
arise.
bEST,
Pavlina
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.
I've shifted the development of this new site to masterpages with a single manager in the master, a limited number of content pages hosting dynamic user controls, and user controls that manage their own activity with a manager proxy. So far this is working well though the added complexity was initially painful to implement.
The thing to remember about all of this is: if you're getting full postbacks instead of partials, try wrapping your controls in a panel or div. That includes content pages, placeholders, and user controls. I don't completely understand this behaviour and it would really help to see a blog or help page that explains in-depth what we should do under various circumstances, and why.
When you need to ajaxify a control with RadAjaxManager, you need to make sure is it available and visible on the page all the time. As dynamic user controls are not always available on the page, it is suggested that you ajaxify their parent container instead of themselves.
For more information, refer to the following articles:
Add AjaxSettings programmatically
Show RadAjaxLoadingPanel on initial page load
Greetings,
Pavlina
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.
As far as wiring, I've found that nested components don't always show up in the RadAjaxManagerProxy when they're inside a Panel - the designer code isn't looking within the controls of all panels, and if you have nested dynamic UCs the designer wouldn't know about them anyway. So rather than using the proxy designer at all anymore, I've created a standard method to be executed at PreRender time for all controls and pages, to programmatically AddAjaxSettings for all required controls in any given control set.
As far as ajaxifying entire Panels that contains controls, I've been thinking that doing this would cause all controls in the panel to get processed on any postback, which can be overkill, so I've been trying to avoid using AddAjaxSetting(PanelX,PanelX) and I'm just specifying every required control. Is this the correct approach?
It is something like this:
//get the Ajax manager |
RadAjaxManager aM = RadAjaxManager.GetCurrent(Page); |
if (aM == null) { |
Response.Write("XFileExplorer needs an Ajax manager in the page holding the control!"); |
Response.End(); |
return; |
} |
//calling Ajax function changes grid and hidden fields - so add settings |
AjaxSetting aS = new AjaxSetting(aM.ID); |
//here add what we have to do |
If an other control on the page want's to ajaxify my usercontrol it must add the ajax settings for it.
Regards
Manfred
It seemed to be working for a while but unfortunately now I'm finding that on every ajax postback I need to completely repopulate controls in order to process events. For a grid in a UC on a panel on a content page within a master, there is no selected item when processing events. I'm sure I'm doing something dreadfully wrong now, and while I've been learning a lot over the last week I really need to move forward with this stuff.
Manfred, I sent you a Skype note to discuss for-fee consulting. I'll try to email at PPP.