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

radajaxmanager control on multiple usercontrol.

25 Answers 1048 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
nitesh monga
Top achievements
Rank 1
nitesh monga asked on 21 Jan 2009, 10:39 AM

Hi there, sorry for posting the same question again, I am facing a problem while using multiple ajaxmanagers with JS  $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Reset");

below is the details about the problem:

======> Main.aspx (is not a master page it’s a normal .aspx page)
            #
            #
            #=========> usercontrol1.ascx (this control is dynamically added to the Main.aspx page)
                                   ( it has the 1 radgrid, 1 radajaxmanage, 1 textbox)    
                                    ( while typing the text on the textbox i fire a JS event which fire a ajax request using this code
                                     $find(
"<%= RadAjaxManager1.ClientID %>").ajaxRequest("Reset"); )
            #
            #
            #=========> usercontrol2.ascx (this control is dynamically added to the Main.aspx page)
                                   ( it has the 1 radgrid, 1 radajaxmanage, 1 textbox)    
                                    ( while typing the text on the textbox i fire a JS event which fire a ajax request using this code $find(
"<%= RadAjaxManager1.ClientID %>").ajaxRequest("Reset"); )

there are two controls which are dynamically added on the main.aspx page, each control has its own radajaxmanager and fires a ajaxrequest using the JS function. if i add only one control to the page it works fine but as soon as I add the other control i start getting the "single instance" error message of radajax manager. I found few articles on the same but was not able to find the solution.

If there is any other example which solves the same problem kindly post it here



thanks aton
nitesh monga

            

25 Answers, 1 is accepted

Sort by
0
nitesh monga
Top achievements
Rank 1
answered on 22 Jan 2009, 07:34 PM
i was able to make it work using :

Dim manager As RadAjaxManager = RadAjaxManager.GetCurrent(Me.Page)
        AddHandler manager.AjaxRequest, AddressOf manager_AjaxRequest


thanks alot
ntiesh monga
0
Tim
Top achievements
Rank 1
answered on 28 Jan 2009, 03:39 AM
Nitesh,
I have a simiar issue here:
http://www.telerik.com/community/forums/aspnet-ajax/ajax/multiple-radajaxmanager-s-in-my-unique-application.aspx

Where I'm experiencing issues with my controls on in a parent/child thats loaded dynamically.
What does :

Dim manager As RadAjaxManagerRadAjaxManager = RadAjaxManager.GetCurrent(Me.Page) 
AddHandler manager.AjaxRequest, AddressOf manager_AjaxRequest 


do? Also, its been a while since I've seen a VB application, however I dont think the above code would run. I took the liberty of sticking it into a code block just to try to figure out where your end line(s) are (?).

Thanks in advance for any help.
Tim


0
nitesh monga
Top achievements
Rank 1
answered on 28 Jan 2009, 07:26 AM
hi tim,

try the below approach

Parent.aspx

 

<telerik:RadAjaxManager ID="AjaxManager1" runat="server">  
        </telerik:RadAjaxManager> 
 

Child.ascx

<telerik:RadAjaxManagerProxy  id="RadAjaxManager1" runat="server">  
        <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="submitButton">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        </AjaxSettings> 
</telerik:RadAjaxManagerProxy > 

<

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

 

 

 

        <

script language="javascript" type="text/javascript">

 

 

      
            // when this TestFunction() JS function is called, an ajax postback request will be fired which will
            // handled by the handler manager_AjaxRequest added in .vb file 
            function

TestFunction() 
                { 

 

 

 

                    $find(

"<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindGrid");

 

 

 

                }

 

         </

script>

 

 

 

</

telerik:RadCodeBlock>

 

 

 

 


child.ascx.vb

        Dim manager1 As RadAjaxManager  
 
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load  
            manager1 = RadAjaxManager.GetCurrent(Me.Page)  
            manager1.AjaxSettings.AddAjaxSetting(manager1, RadGrid1)  'this will update the radgrid on submit button click
            AddHandler manager1.AjaxRequest, AddressOf manager_AjaxRequest 'this handler will invoked when there is a ajax
            postback request on your child control
         End Sub
         
         

 

        Private Sub manager_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)

             

 If (e.Argument = "RebindGrid") Then

 

 

                RadGrid1.Rebind()

 

 

            End If
         End Sub

 

 

 

 


lemme know if the above code solved the problem

thanks
nitesh monga
0
Tim
Top achievements
Rank 1
answered on 28 Jan 2009, 08:35 AM
In your code, I'm looking at the parameters for the proxy -- do they wire up only submitButton and RadGrid1, if so, can I also define the RadAjaxManager/RadScriptManager?

I think if I can define the manager only the controls that need it, it will stop the problems I'm having with the parent.aspx controls. Let me know your thoughts.

        <AjaxSettings>  
        <telerik:AjaxSetting AjaxControlID="submitButton">   
            <UpdatedControls>  
                <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>  
            </UpdatedControls>  
        </telerik:AjaxSetting>  
        </AjaxSettings> 
0
Iana Tsolova
Telerik team
answered on 29 Jan 2009, 07:07 AM
Hello Tim,

Please review the below articles for further information about loading user controls with ajax and RadAjax with UserControls:

http://www.telerik.com/help/aspnet-ajax/ajxusercontrols.html
http://www.telerik.com/help/aspnet-ajax/ajxloadusercontrols.html
http://www.telerik.com/help/aspnet-ajax/ajax-manager-proxy.html
http://demos.telerik.com/aspnet-ajax/Ajax/Examples/Common/LoadingUserControls/DefaultCS.aspx

Check it out and let me know if any questions arise.

Best wishes,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tom
Top achievements
Rank 1
answered on 04 Feb 2009, 08:50 PM
I had a similar issue where I had multiple usercontrols that launched RadWindows for editing their content, and I needed to find a way to refresh the usercontrol upon close of the RadWindows (via their OnClientClose).  The main examples on the Telerik site suggest a method where we handle the AjaxRequest within the main window, but thank you Nitesh Monga for posting this solution that allows handling the AjaxRequest within the UserControl!  This worked perfectly for me.

-- Tom Huleatt
0
Wired_Nerve
Top achievements
Rank 2
answered on 23 Feb 2009, 05:34 PM
I am having similar issues but in C#.  Oddly enough,  when i enter the following code in the page load event:

 protected void Page_Load(object sender, EventArgs e)  
        {  
            RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);  
            manager.ClientEvents.OnRequestStart = "onRequestStart";  
            manager.ClientEvents.OnResponseEnd = "onResponseEnd";  
            manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest); 

I get a error in visual studio 2008 that says the following:
"The name 'manager_AjaxRequest' does not exist in the current context.'"

Any ideas?
0
Tom
Top achievements
Rank 1
answered on 23 Feb 2009, 06:06 PM
Warren,

Forgive the obvious question, but...
    Have you defined a "manager_AjaxRequest" function?  (You're passing the name of your handler here.)  That function can be very simple, such as the VB subroutine used earlier in this thread:
Private Sub manager_AjaxRequest(ByVal sender As ObjectByVal e As AjaxRequestEventArgs)   
    If (e.Argument = "RebindGrid"Then   
        RadGrid1.Rebind()   
    End If 
End Sub 

--Tom
0
Wired_Nerve
Top achievements
Rank 2
answered on 23 Feb 2009, 07:10 PM
I had previously had such a function when trying to just use the AjaxManager, but I removed it since I was tyring to figure out how to use the proxy tool.  Should I put this AjaxRequest code on the Primary page or on the User Control page?  Working with Ajax and the Telerik controls is very new to me, so I am still kind of wondering around lost in the forest, or so it seems to me...





0
Wired_Nerve
Top achievements
Rank 2
answered on 23 Feb 2009, 07:51 PM
The part I am having issues with is that the code uses a masterpage which uses a RadWindowManager that opens a window when you click a button in a grid control,  The gridcontrol is part of a user control.

So I am trying to figure out where each of the various controls (Ajax Manager and the proxy) should go.
I figure the proxy should be on the user control.  I believe the RadAjaxManager should either be on the Master Page or the client page that contains the user control. Plus, I am tyring to figure out where (in your example) I would put the TestFuction, which I thought would go on the client page, but in my instance may belong on the master page... grrrr
 

Basically this is what happens.  The user loads a page that has various data points on it.  A User control list all vehicles the user owns.  They can then edit a row in the grid and then decide to add additional colors to a drop down list control (contained in that editing row) by clicking on a imagebutton.  When they click the image button, a Window is opened up where they can edit, add, or delete colors from a list.  When they close this window, that is when I need the grid to refresh and the dropdown list will now need to have the changed or added values in it.

etc...etc..

0
Tom
Top achievements
Rank 1
answered on 23 Feb 2009, 08:34 PM

Warren,

I went through a similar discovery process last month.

 

You're right: you can put the RadAjaxManager on the master page or on the info page.  (I would opt for the master page if most of the info pages are using Ajax.)

 

If you want to establish some AJAX dependencies at design-time, you could place a RadAjaxManagerProxy in your control.  You probably want to use it to set up a case where your grid is both the initiator and the updated control (i.e. postbacks from the grid should update the grid).  You could also do this at run-time -- without having to use a RadAjaxManagerProxy -- by using AddAjaxSetting (see the child.ascx.vb code in Nitesh Monga's post from Jan 28 in this thread). 

 

It looks like it will make sense to handle the ajaxrequest for the updated color palette within your control, so add a function (e.g. manager_AjaxRequest) to your web user control that simply looks for the argument -- something like "UpdateColorsInGrid" -- that you passed into the client-side .ajaxRequest call.  In that function do whatever it is you need to do to update the color dropdown and redisplay the grid.  That function name is the one that you should reference as your new AjaxRequestDelegate.

Hope this helps,
Tom Huleatt

0
Wired_Nerve
Top achievements
Rank 2
answered on 23 Feb 2009, 08:44 PM
Thanks a ton, that just confirms I am not barking up the wrong tree! 


Again thanks!

Warren
0
Gabriel
Top achievements
Rank 1
answered on 14 May 2009, 05:43 PM
Hi Nitesh.
I´m migrating a software produt from RadControls 2006 to RadAJax COntrols Q1 2009.
Alote has change since then...
I´ve seen your post and you have a situation very similar to mine.
I´ve also have a main_page.aspx (that is not a MasterPage)
And I also load dynamically usercontrols in that main_page.

My problem is that I´ve take the road that you said, but instead of calling a button in

<telerik:AjaxSetting AjaxControlID="submitButton">  

I'm putting a RadToolbar.
And I want to Update a RadGrid depending on the RadToolbarButton clicked


PROBLEM?

My RadTab don´t fire the ButtonClick event never, no mather what radtoolbar i click.
I ´ve tried everything but still nothing happended.
If i put the RadAjaxManager directly in the user control it fires the ButtonClick event, but I can´t do that because, you already know, i can only have one radajaxmanager  and I already have one in the main_page

Here is the example code


main_page.aspx

 <asp:scriptmanager id="scriptManager" runat="server">
        <Services>
            <asp:ServiceReference path="~/UserControls/MailingLists/MailingListScriptService.asmx" />
            <asp:ServiceReference path="~/UserControls/Scheduler/SchedulerScriptService.asmx" />
        </Services>
    </asp:scriptmanager>
    <!-- Telerik RadAjaxManager -->
     <telerik2009:RadAjaxManager runat="server" ID="telerikAjaxManager" />

Usercontrol.ascx

<telerik2009:RadAjaxManagerProxy ID="RadAjaxManagerProxy" runat="server" > 
        <AjaxSettings> 
            <telerik2009:AjaxSetting AjaxControlID="MainRT"> 
                <UpdatedControls> 
                    <telerik2009:AjaxUpdatedControl ControlID="gridJobs"></telerik2009:AjaxUpdatedControl> 
                </UpdatedControls> 
            </telerik2009:AjaxSetting> 
        </AjaxSettings> 
</telerik2009:RadAjaxManagerProxy> 

<telerik2009:RadCodeBlock ID="RadCodeBlock1" runat="server">  
            function myContentClickHandler() {
                $find("<%= Telerik.Web.UI.RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("FireRadTab");
     
     }
    </telerik2009:RadCodeBlock> 
   

<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
    <tr>
        <td background="service/res/OtlBlueBar.gif" style="height: 20px">
 
    <telerik2009:RadToolbar ID="MainRT" runat="server" SkinID="Default" OnButtonClick="MainRT_OnClick" CausesValidation="false">
        <Items>
            <telerik2009:RadToolBarButton runat="server" ID="StartGroup" ImageUrl="~/App_Themes/Default/Images/16x16/Start.gif"
                ButtonText="Start" ToolTip="Start a job group" />
            <telerik2009:RadToolBarButton runat="server" ID="PauseGroup"  ImageUrl="~/App_Themes/Default/Images/16x16/Pause.gif"
                ButtonText="Pause" ToolTip="Pause a job group" />
            <telerik2009:RadToolbarButton runat="server" ID="CancelGroup"  ImageUrl="~/App_Themes/Default/Images/16x16/Stop.gif"
                ButtonText="Cancel" ToolTip="Cancel a job group" />
            <telerik2009:RadToolBarButton IsSeparator="true" />
            <telerik2009:RadToolbarButton runat="server" ID="ApproveGroup" ButtonText="Approve" ToolTip="Approve a job group"  ImageUrl="~/App_Themes/Default/Images/16x16/Checked.gif" />
            <telerik2009:RadToolBarButton IsSeparator="true" />
            <telerik2009:RadToolbarButton runat="server" ID="ViewHistory" SkinID="HistoryButton"
                CommandName="ViewHistory" ButtonText="View history" ToolTip="View job group history"  ImageUrl="~/App_Themes/Default/Images/16x16/JobHistory.gif"/>
            <telerik2009:RadToolbarButton runat="server" ID="ViewErrors"  ButtonText="View Errors" ToolTip="View errors associated with the group" ImageUrl="~/App_Themes/Default/Images/16x16/JobError.gif" />
            <telerik2009:RadToolBarButton IsSeparator="true" />
            <telerik2009:RadToolbarButton runat="server" ID="ResendJobButton" ImageUrl="~/App_Themes/Default/Images/16x16/Resend.gif" ButtonText="Resend" ToolTip="Resend a job group" />
        </Items>
    </telerik2009:RadToolbar>
            <asp:Label ID="lb_tableName" Font-Names="Arial" Font-Size="15px" Font-Bold="True"
                ForeColor="White" runat="server">Manage Scheduler</asp:Label>
            <asp:Button ID="Button1" runat="server" /> 
        </td>
    </tr>
</table>



usercontrol.ascx.vb

Dim manager1 As Telerik.Web.UI.RadAjaxManager

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles Me.Load
        popStatus.Visible = False

        manager1 = RadAjaxManager.GetCurrent(Me.Page)
        manager1.AjaxSettings.AddAjaxSetting(manager1, gridJobs)  
        AddHandler manager1.AjaxRequest, AddressOf manager_AjaxRequest 
    End Sub

    Private Sub manager_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
        If (e.Argument = "FireRadTab") Then
                .......
                
                        I never enter here, and I don´t know if I need this Method, do I??????

                ........
        End If
    End Sub


 Protected Sub MainRT_OnClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs)

    .......
        
        This is the method that I want to enter when clicking in one of the radtoobarbuttons

    ......
 End Sub


If there is any other example which solves the same problem kindly post it here .

Thanks nitesh

Gabriel
0
Sebastian
Telerik team
answered on 15 May 2009, 08:51 AM
Hi Gabriel,

See the reply in the other forum thread you opened with regards to this subject:
http://www.telerik.com/community/forums/aspnet-ajax/ajax/scriptmanagerproxy-problem.aspx

Additionally, for the same type of scenario consider using single RadAjaxManager on the main page and RadAjaxManagerProxy control inside the user control:

http://demos.telerik.com/aspnet-ajax/ajax/examples/manager/usercontrol/defaultcs.aspx

Best regards,
Sebastian
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.
0
Gabriel
Top achievements
Rank 1
answered on 18 May 2009, 02:18 PM

Hi thanks for your attention,
 
first of all

"See the reply in the other forum thread you opened with regards to this subject:
http://www.telerik.com/community/forums/aspnet-ajax/ajax/scriptmanagerproxy-problem.aspx"

I´ve seen it, you say I should use a ScriptManagerProxy.

But in this thread you say to use the RadAjaxManagerProxy.

Where do we stand, use the ScriptMAnagerProxy will do the trick our the both??

Thanks in advanced.

All the recommended links you send to me I´ve already been there.

In fact I have read everything about RadAjaxManager and I can´t resolve this problem

QUestion?

When I load my Usercontrols in code-behind in the main_page, do I have to define their ID each time I load them?

Thanks

0
Sebastian
Telerik team
answered on 21 May 2009, 11:52 AM
Hello Gabriel,

You can use both controls (ScriptManagerProxy and RadAjaxManagerProxy) in master -> content page or page -> user control scenario to register scripts or apply ajax settings respectively. Additionally, how to load user controls programmatically and ensure that their viewstate/lifecycle will remain consistent you can see from the examples below:

http://demos.telerik.com/aspnet-ajax/ajax/examples/common/loadingusercontrols/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/ajxloadusercontrols.html

Best regards,
Sebastian
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.
0
Andre
Top achievements
Rank 1
answered on 23 Jun 2009, 06:17 PM
Hi,

I'm a new user of the Telerik controls and AJAX. I'm having a difficult time keeping my user control "ajaxified" when it is loaded dynamically to the page using LoadControl. It works fine when it's on a page declaratively but not when it's loaded in the code behind.

Here's a .aspx page with the user control that works:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    </telerik:RadAjaxManager> 
    <uc2:uViewProfile ID="AssociateProfile" runat="server" /> 
</asp:Content> 
 

The user control .ascx file has the following code: (just the relevant bits shown)

        <telerik:RadPageView ID="RadPageView1" runat="server"
            <uc1:uProfileGeneral ID="ProfileGeneral" runat="server" /> 
            <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="ProfileGeneral"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="ProfileGeneral" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdServices" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdCommunications" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdEmails" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdAddresses" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdSales" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdHistory" /> 
                            <telerik:AjaxUpdatedControl ControlID="grdDesignations" />                             
                            <telerik:AjaxUpdatedControl ControlID="grdLicenses" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManagerProxy> 
        </telerik:RadPageView> 

However, if I load that same user control into another page (.aspx example that doesn't work):

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="btnQuickSearch"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadMultiPageMain" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="btnAdvancedSearch"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadMultiPageMain" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="RadGridSearchResults"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadMultiPageMain" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting>                 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
 
(snip....) 
 
                            <telerik:RadPageView ID="RadPageViewDisplaySelectedProfile" runat="server" Width="100%"
                                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> 
                            </telerik:RadPageView> 
 

Then in the code behind (.vb) , I load the user control into the PlaceHolder1 shown above:

    Private Sub RadGridSearchResults_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridSearchResults.ItemCommand 
 
        If e.CommandName = VIEW_PROFILE_COMMANDNAME Then 
            'Get the ProfileID (hidden column/cell) from the selected row. 
            AppSession.SelectedProfileIDToView = e.Item.Cells(3).Text 
 
            LoadUserControl("~\uViewProfile.ascx", True) 
 
            'Select the Display Profile tab in the tab strip. 
            RadTabStripMain.SelectedIndex = TAB_INDEX_PROFILE 
            RadTabStripMain.Tabs(TAB_INDEX_PROFILE).Selected = True 
            'Select the Display Profile page in the multipage. 
            RadMultiPageMain.SelectedIndex = TAB_INDEX_PROFILE 
 
        End If 
 
    End Sub 
 
    Private Sub LoadUserControl(ByVal controlPath As String, ByVal isFirstLoad As Boolean) 
        Dim control As Control = LoadControl(controlPath) 
        control.ID = Utility.GetControlID(controlPath) 
        PlaceHolder1.Controls.Clear() 
        PlaceHolder1.Controls.Add(control) 
        If isFirstLoad Then 
            RadAjaxManager1.Alert("First Load!") 
            TryCast(control, IDynamicControl).FirstLoad() 
        End If 
    End Sub 

The user control loads and displays fine after being dynamically loaded and added to the PlaceHolder. However, if I click on my edit link or refresh any of the RadGrids inside that user control, it does a full postback (with full page refresh) instead of doing an Ajax callback as wanted based on the RadAjaxManagerProxy settigns inside the user control.

Keep in mind that the same user control is fully Ajax enabled when declaratively loaded in the page in the simple first example.

How do I resolve this and activate my Ajax callbacks in my user control when added to a page with LoadControl?

Any help will be greatly appreciated.

Thanks!

Andre






0
Sebastian
Telerik team
answered on 24 Jun 2009, 11:10 AM
Hello Andre,

Loading user controls inside postback event handlers (ItemCommand server event of a grid instance in this case) is a bit late stage in the page lifecycle to maintain the viewstate of the user control consistent. You will need to modify your logic based on the online resources pointed below:

http://demos.telerik.com/aspnet-ajax/ajax/examples/common/loadingusercontrols/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/ajxloadusercontrols.html

to ensure that the user control will be loaded properly programmatically. Thus its lifeycle/viewstate will remain intact and the controls inside it should function as expected.

Best regards,
Sebastian
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.
0
Andre
Top achievements
Rank 1
answered on 24 Jun 2009, 03:24 PM
Hi Sebastian,

You say that loading controls in a server side postback event handler is late stage, yet that is exactly what the example you pointed me to does. I have looked at that example before and the lbl_click handlers (which is a server-side postback event handler) do the LoadControl method.

It seems the difference with the example is that they do the LoadControl method again inside the Page_load event. So it seems like it will do the LoadControl twice? Is that correct?

If the user control should be loaded in Page_init or Page_load, why even load it in the click handler? Maybe the click handler should just save a value of the control selection so the Page_load knows which user control to load?

Doesn't it seem redundant to do LoadControl twice?

The reason I put my load control in the ItemCommand handler for the RadGrid was because the person does a search which results in a list of matches inside a grid. Each row of the grid has a link button which will select that item and do the load control to get the details of that item into a tab on the RadTabStrip.

In fact, at first what we wanted to do was upon clicking the item in the RadGrid, we wanted the ItemCommand event to created a New RadTab and add it to the RadTabStrip, then create a New RadPageView (of a RadMultiPage) and then load the user control and add it to the new RadPageView (that the RadTab would display).

Maybe I'm thinking about this all wrong, but as I mentioned, I'm new to the Rad controls and I'm not sure how best to use them.

If you have suggestions on how I should approach this, I'd like to hear them.

Thanks.

Andre
0
Sebastian
Telerik team
answered on 24 Jun 2009, 03:32 PM
Hello Andre,

Please examine the explanation/code snippets from the help topic referenced in my previous reply and modify your implementation to conform to the conventions explained there. This should produce the desired result when loading user controls with ajax programmatically.

Kind regards,
Sebastian
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.
0
Andre
Top achievements
Rank 1
answered on 24 Jun 2009, 04:29 PM
Hi again,

I looked at my code again and realized that I *did* have the LoadControl inside my Page_load handler. Here's the code snippet I forgot to include in my first post:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
 
        LoadUserControl("~\uViewProfile.ascx", Not IsPostBack) 
    End Sub 

So I have LoadControl in the Page_Load and in the grid ItemCommand very similar to the example.

I still have the problem in that my user control is no longer "ajaxified" after loading it dynamically. Perhaps I have to put my dynamic control inside an asp:panel instead of an asp:placeholder? Don't see how that can make a difference.

I will have to keep experimenting. Unfortunately, this is frustrating and is delaying my project by a few days now.

Andre


0
Andre
Top achievements
Rank 1
answered on 24 Jun 2009, 10:04 PM
After much experimenting (pretty much the whole day) and simplifying the page and then building it back up again, I discovered the problem.

    Private Sub RadGridSearchResults_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridSearchResults.ItemCommand 
 
        If e.CommandName = VIEW_PROFILE_COMMANDNAME Then 
            'Get the ProfileID (hidden column/cell) from the selected row. 
            AppSession.SelectedProfileIDToView = e.Item.Cells(3).Text 
 
            LoadUserControl("~/uViewProfile.ascx", PlaceHolder1, True) ' Fixed this line. Had backslash \ instead of forward slash / after tilde ~ 
 
            'Select the Display Profile tab in the tab strip. 
            RadTabStripMain.SelectedIndex = TAB_INDEX_PROFILE 
            RadTabStripMain.Tabs(TAB_INDEX_PROFILE).Selected = True 
            'Select the Display Profile page in the multipage. 
            RadMultiPageMain.SelectedIndex = TAB_INDEX_PROFILE 
 
        End If 
 
    End Sub 

My guess is that with the backslash, the AjaxManager wasn't finding the control by it's ID and thus was doing a regular postback. I noticed this by hovering over a linkbutton that was showing the __doPostBack('uc_\uViewProfile','') instead of 'uc_uViewProfile' on another test I was doing.

This was a tough nut to crack, so I'm posting this here so that others may benefit from my investigation.

On a somewhat related topic...while testing this, I ran into the Telerik controls giving several JavaScript errors with the RadScriptManager and RadAjaxManager on a Master page and my control loaded inside a content page using that Master page. Once I set the page to not use the Master and have the RadScriptManager directly on the page, things started working. Using the Master page, my RadSplitter was non-functional (couldn't resize my panes as the cursor wouldn't change to the double arrow and I couldn't click and drag on the RadSplitBar).

Any ideas on that one? Is it not possible to put the RadScriptManger on the Master page with the RadSplitter, RadSplitBar and RadPanes in a user control in a Content page?

Thanks!

Andre


0
Sebastian
Telerik team
answered on 25 Jun 2009, 07:25 AM
Hello Andre,

I am glad that you addressed the issue with the dynamic loading of user controls with ajax - thank you for posting it in this public forum thread.

Concerning your additional question:
Although based on your description I cannot say for certain where the exact source of the issue can be, can you please test whether setting EnableScriptsCombine = false for the RadScriptManager instance or replacing it with regular asp ScriptManager alleviates the abnormality? You may also perform some troubleshooting using the guidelines from this documentation topic.

Kind regards,
Sebastian
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.
0
Andre
Top achievements
Rank 1
answered on 25 Jun 2009, 08:26 PM
Thanks Sebastian.

I tried the two suggestions you mentioned: I set EnableScriptCombine = "false" for the RadScriptManager instance and also replaced it with regular asp ScriptManager. Neither test worked. Then I removed the RadScriptManager and replaced it and started getting an error saying that the ID for RadScriptManager1 already existed in another control.

Thinking that Visual Studio 2008 was perhaps screwing up, I closed the solution and re-opened it. Then I even shut down VS2008 and restart it. Still broken.

However, I did a project search and the only definition for RadScriptManger1 was in my Test.Master file. Then I looked in my web.config and removed the handlers for the Telerik script manager. Then I re-registered the script manager from the smart tag on the Master page and it started working again (no JavaScript errors on page load now).

I have no idea why this fixed it. Seems like moving the RadScriptManager and RadAjaxManager around from content page to Master page messed it up.

Any explanation as to why you'd have to remove the handler and re-register the RadScriptManager in web.config?

Andre


0
Sebastian
Telerik team
answered on 26 Jun 2009, 08:19 AM
Hello Andre,

This is quite an odd behavior and I suspect that is due to some specific configuration settings which were properly reset when you performed this sequence of operations. I am happy to hear that everything works as expected now.

Kind regards,
Sebastian
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.
Tags
Ajax
Asked by
nitesh monga
Top achievements
Rank 1
Answers by
nitesh monga
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Iana Tsolova
Telerik team
Tom
Top achievements
Rank 1
Wired_Nerve
Top achievements
Rank 2
Gabriel
Top achievements
Rank 1
Sebastian
Telerik team
Andre
Top achievements
Rank 1
Share this question
or