This is a migrated thread and some comments may be shown as answers.

Dynamic user controls generated on Tab Click with RenderSelectedPageOnly

3 Answers 94 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Leslie Shkolnik
Top achievements
Rank 1
Leslie Shkolnik asked on 19 Dec 2008, 01:24 AM

I have a tab strip and a multip page with RenderSelectedPageOnly set to true.  When I click on a tab, I am loading a user control into an asp:Panel on the pageview.  I am re-loading the user control on a postback and that seems to be working fine.

In general, Inside the user control, where is the proper event in order to set the ajax settings programmatically to update controls on the page after an ajax call?  If I use OnLoad or PageLoad, it can't find the control to be updated.  I am currently using OnPreRender.

More specifically, inside the user control I have a grid.  In the onLoad event,  I add a RadAjaxManager.GetCurrent(Page).ResponseScripts.Add to call a client side function which issues an ajax call back to the server to load the contents of the grid.  Basically, I want to see the control, and then load the contents of the grid with an ajax call.  This is all functioning properly, however the grid is NOTupdated after the ajax call.  In the server side ajax request, I am adding an ajax setting for the mgr as the initiator and the grid as the target.  If I look at the rendered source for the page, I have 2 panels generated for the grid with the same id!  One has no data, and the other does have data.  In OnPreRender, I add an ajax setting for the grid to update itself in order to have the panel generated in the first place.

What am I doing wrong?

Thanks,

Leslie

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 20 Dec 2008, 03:21 PM
Hello Leslie,

Could you please check if you experience the same behavior if the default page view displayed is one with RadGrid in its content?

Additionally, please review this help topic on RadGrid visible/invisible conventions.

Let me know how it goes.

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Leslie Shkolnik
Top achievements
Rank 1
answered on 22 Dec 2008, 08:23 PM
I figured out my problem with the grid.  However, I would still like an answer to the general question -- when is the appropriate place in a user control's life cycle to programmatically add ajax settings in this scenario?  The first control that loads in the tab strip when the page is loaded won't work with the ajax settings in the ascx -- I get an undefined is null or not an object in some javascript buried in an 

initializeBase call.  But it works if I programmatically put the settings in PreRender.  The second tab works with the settings in the ascx.

0
Iana Tsolova
Telerik team
answered on 23 Dec 2008, 11:13 AM
Hi Leslie,

When  adding AJAX settings dynamically (at runtime), you should always do this in a Page event handler, which is executed each time during the page lifecycle (Page_Load, Page_PreRender). And note that you need to assure that the controls that take part in the AJAX settings are available on the page. 

Therefore in of dynamically loaded controls, I suggest that you create the ajax setting on Page_PreRender where all the controls are loaded already for sure.
 
Kind regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Leslie Shkolnik
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Leslie Shkolnik
Top achievements
Rank 1
Share this question
or