Exclude Panel from update in Ajax request

4 posts, 0 answers
  1. Kin
    Kin avatar
    12 posts
    Member since:
    Aug 2013

    Posted 09 Jun 2015 Link to this post

    Hi all, please help with implementing below logic.

    <asp:Button id="btn1" /> 
    <asp:Panel id="pnlMain">
         <asp:Button id="btn2" />
         <asp:Panel id="pnlInner"> </asp:Panel>
    </asp:Panel>

     

    Ajaxified by:

    RadAjaxMagager.AjaxSettings.AddAjaxSetting(btn1, pnlMain);
    RadAjaxMagager.AjaxSettings.AddAjaxSetting(btn2,pnlInner);

    Issue is: Then I clicking btn2, pnlMain updates too. I do not want to pnlMain to be updated on click btn2.
    Is it possible? Why does it updates?



  2. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 12 Jun 2015 Link to this post

    Hello Kin,

    You can achieve this requirement using the following approach:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
                OnAjaxSettingCreated="RadAjaxManager1_AjaxSettingCreated">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="btn1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="pnlMain" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="btn2">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="pnlInner" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <asp:Button ID="btn1" runat="server" Text="Update All" />
            <asp:Panel ID="pnlMain" runat="server" Style="background-color: lightgreen; padding: 5px; width: 200px">
                <asp:Label ID="Label1" runat="server" Text="Label" OnLoad="Labels_Load"></asp:Label>
                <br />
                <br />
                <asp:Button ID="btn2" runat="server" Text="Update Inner" />
                <asp:Panel ID="pnlInner" runat="server" Style="background-color: Highlight; padding: 5px;">
                    <asp:Label ID="Label2" runat="server" Text="Label" OnLoad="Labels_Load"></asp:Label>
                </asp:Panel>
            </asp:Panel>
    C#:
    protected void Labels_Load(object sender, EventArgs e)
    {
        (sender as Label).Text = DateTime.Now.ToLongTimeString() + "." + DateTime.Now.Millisecond;
    }
    protected void RadAjaxManager1_AjaxSettingCreated(object sender, AjaxSettingCreatedEventArgs e)
    {
        if (e.Initiator == btn1)
        {
            e.UpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
            e.UpdatePanel.ChildrenAsTriggers = false;
            e.UpdatePanel.Triggers.Add(new AsyncPostBackTrigger() { ControlID = "btn1" });
        }
    }

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kin
    Kin avatar
    12 posts
    Member since:
    Aug 2013

    Posted 12 Jun 2015 in reply to Eyup Link to this post

    Hi Eyup, I was trying your solution, but seems it is not working.
    But thanks for directing me a right way. My solution listed below.
    What you think about it? How right is it?


    void CurrentRadAjaxManager_AjaxSettingCreated(object sender, AjaxSettingCreatedEventArgs e)

            {
                if (e.UpdatePanel.ID.EndsWith(pnlMain.ID + "Panel"))
                {
                    e.UpdatePanel.ChildrenAsTriggers = false;
                }
            }

  5. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 17 Jun 2015 Link to this post

    Hello Kin,

    I'm glad the suggested direction has proven helpful in finding a viable solution for your scenario.
    Please feel free to turn to us if new questions arise.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top