Incorrect AJAX behaviour

3 posts, 0 answers
  1. Alexander
    Alexander avatar
    2 posts
    Member since:
    Jul 2013

    Posted 22 Jan 2014 Link to this post

    Hi,

    Take a look at this scenario: there's a page (inherited from Master Page) containing a user control. This control contains a RadWindow and a button to show the window. 
    Master Page:
    <body>
        <form id="form1" runat="server">
     
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
     
        <%-- This shouldn't be modified --%>
        <telerik:RadAjaxManager ID="RadAjaxManager1" UpdatePanelsRenderMode="Inline" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ContentPlaceHolder1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ContentPlaceHolder1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
     
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
        </form>
    </body>

    Page:
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="WebUserControl1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="WebUserControl1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
     
        <uc1:WebUserControl1 runat="server" ID="WebUserControl1" />
    </asp:Content>

    Control.aspx:
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Button2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Button2" />
                    <telerik:AjaxUpdatedControl ControlID="Label2" />
                    <telerik:AjaxUpdatedControl ControlID="RadWindow1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
     
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function f()
            {
                var clientWin = $find('<%= RadWindow1.ClientID %>');
                clientWin.show();
            }
        </script>
    </telerik:RadScriptBlock>
     
    <asp:Button ID="Button1" runat="server" Text="ShowWindow" OnClientClick="f(); return false;" />
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
     
    <telerik:RadWindow ID="RadWindow1" ReloadOnShow="true" runat="server" OnClientClose="OnClientclose">
        <ContentTemplate>
            <asp:Button ID="Button2" runat="server" Text="Change labels" OnClick="Button2_Click"/>
            <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
        </ContentTemplate>
    </telerik:RadWindow>
    Control.cs
    protected void Button2_Click(object sender, EventArgs e)
    {
        Label2.Text = "222";
        Label1.Text = "111";
    }

    When Button2 is clicked, the window closes and both of the labels change. How to fix this problem keeping code on Master Page unchanged?

    Thanks in advance.
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 22 Jan 2014 Link to this post

    Hi Alexander,

    In this case you should remove all the Ajax settings form the parent pages and simply warp the Button and the Label from the RadWindow content template with a RadAjaxPanel control.
    <telerik:RadWindow ID="RadWindow1" ReloadOnShow="true" runat="server" OnClientClose="OnClientclose">
        <ContentTemplate>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <asp:Button ID="Button2" runat="server" Text="Change labels" OnClick="Button2_Click"/>
            <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </telerik:RadAjaxPanel>
        </ContentTemplate>
    </telerik:RadWindow>

    Give this a try and verify if it helps.


    Regards,
    Maria Ilieva
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alexander
    Alexander avatar
    2 posts
    Member since:
    Jul 2013

    Posted 23 Jan 2014 Link to this post

    Hi Maria,

    Yes it helps, thanks!
Back to Top