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

Exclude Panel from update in Ajax request

3 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kin
Top achievements
Rank 1
Kin asked on 09 Jun 2015, 08:46 AM

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?



3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Jun 2015, 09:29 AM
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
0
Kin
Top achievements
Rank 1
answered on 12 Jun 2015, 01:53 PM

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;
            }
        }

0
Eyup
Telerik team
answered on 17 Jun 2015, 10:22 AM
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
Tags
General Discussions
Asked by
Kin
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Kin
Top achievements
Rank 1
Share this question
or