Update control in master page from ajaxified button in content

2 posts, 0 answers
  1. Blop
    Blop avatar
    19 posts
    Member since:
    Feb 2012

    Posted 25 May 2012 Link to this post

    Hi

    Here's my issue: I ve a button in my content page, on click I want to upload a label in my master page with ajax.

    I've read that: http://www.telerik.com/help/aspnet/ajax/ajxmasterpageupdateeverywhere.html 
    and tried something like that:

    In my content page: 

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load      
               Dim AjaxManager As RadAjaxManager = CType(Me.Master.FindControl("radAjaxManMaster"), RadAjaxManager)
               Dim lbl  As Label = CType(Master.FindControl("myLabel"), Label) 
               AjaxManager.AjaxSettings.AddAjaxSetting(btnAdd, lblCartItemCount, Nothing)   
        End Sub

    Protected Sub btnAjouter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim lbl As Label = CType(Me.Master.FindControl("myLabel"), Label)
                lbl.Text = "New value"
    End Sub

    On the masterpage I ve that: 
     <telerik:RadAjaxManager ID="radAjaxManMaster" runat="server"  DefaultLoadingPanelID="RadAjaxLoadingPanel1">
     </telerik:RadAjaxManager>

    <asp:Label id="myLabel"  runat="server"></asp:Label>


    The loadingpanel is displayed on my label but it keeps the old value...

    What I dont get its that it is rendering page cycle twice (two time page load on master page and contentpage)
    ...
    (When I'm removing the three lines in page load of content page it works as it should (no page event called twice and label is updated but page is postback and no ajax...)) 


    Could someone help me?
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 25 May 2012 Link to this post

    Hi,

    Where is the ScriptManager defined? Its definition should be before this of the RadAjaxmanager.
    In addition, the best way to get reference to the RadAjaxManager object is to use RadAjaxMnager.GetCurrent(Page) method instead of calling FindControl.

    However I prepared a sample page illustrating how you can achieve your goal. There Page_Load is fired as expected on my end. Try it our and let me know if it works for you.

    Greetings,
    Iana Tsolova
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top