First of all, I would like to recall the use of UpdateMode
Always The panel will update its content in each message on the page, they can be partial messages about publication or full messages, in both cases the contents of the panel will be updated
Conditional contents of the panel will be updated only if various conditions are met:
By default, events triggered by its children trigger an update, you can change this behavior parameter ChildrenAsTriggers="false"
When you declare a trigger in the Triggers UpdatePanel section
When you explicitly call the UpdatePanel.Update() method
Full page messages will trigger an update
The following code does the following:
Each UpdatePanel is updated when its child controls raise an event.
UpdatePanel 1 named: up1 will only be updated when its child controls raise an event
UpdatePanel 2 named up2 will update when its child controls raise an event
UpdatePanel 2 with the name up2 will also be updated when triggers are triggered, in this case when DropDownList with the name ddl1OnPanel1 on UpdatePanel 1 starts it SelectedIndexChanged
An UpdatePanel 2 named up2 will also be updated when a DropDownList named ddl2OnPanel1 in UpdatePanel 1 calls its SelectedIndexChanged , because in the code it explicitly calls: this.up2.Update();
I think that with the setup of this code you could achieve the desired goal, just copy it to a new page and run it
Check the following code (see how the labels displaying the date differ depending on the events raised):
Code for
protected void ddl1OnPanel1_SelectedIndexChanged(object sender, EventArgs e) { this.lblMessageOnPanel1.Text = "From ddl1 " + DateTime.Now.ToString(); this.calendarOnPanel2.SelectedDate = DateTime.Today.AddDays(1); this.lblMessageOnPanel2.Text = "From ddl1 " + DateTime.Now.ToString(); } protected void ddl2OnPanel1_SelectedIndexChanged(object sender, EventArgs e) { this.lblMessageOnPanel1.Text = "From ddl2 " + DateTime.Now.ToString(); this.calendarOnPanel2.SelectedDate = DateTime.Today.AddDays(2); this.lblMessageOnPanel2.Text = "From ddl2 " + DateTime.Now.ToString(); this.up2.Update(); }
Aspx
<asp:ScriptManager runat="server" ID="scriptManager" /> <asp:Button Text="Full Post" runat="server" /> <br /> <asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional"> <ContentTemplate> <asp:DropDownList runat="server" ID="ddl1OnPanel1" AutoPostBack="true" OnSelectedIndexChanged="ddl1OnPanel1_SelectedIndexChanged"> <asp:ListItem Text="text1" /> <asp:ListItem Text="text2" /> </asp:DropDownList> <br /> <asp:DropDownList runat="server" ID="ddl2OnPanel1" AutoPostBack="true" OnSelectedIndexChanged="ddl2OnPanel1_SelectedIndexChanged"> <asp:ListItem Text="text3" /> <asp:ListItem Text="text4" /> </asp:DropDownList> <br /> <asp:Label runat="server" ID="lblMessageOnPanel1" /> <br /> <asp:Button ID="Button1" Text="text" runat="server" /> <br /> On every post on Panel 1: <%:DateTime.Now %> </ContentTemplate> </asp:UpdatePanel> <br /> <br /> <asp:UpdatePanel runat="server" ID="up2" UpdateMode="Conditional"> <ContentTemplate> <asp:Calendar ID="calendarOnPanel2" runat="server" > <DayHeaderStyle CssClass="dayheaderStyle" /> <NextPrevStyle /> <OtherMonthDayStyle BackColor="#ffffff" /> <SelectedDayStyle /> <TitleStyle CssClass="titleStyle" /> <TodayDayStyle BackColor="#ffffa0" ForeColor="#6699cc" /> <WeekendDayStyle /> <DayStyle CssClass="dayStyle" /> </asp:Calendar> <br /> <asp:Label ID="lblMessageOnPanel2" runat="server" /> <br /> On every post On Panel 2: <%:DateTime.Now %> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddl1OnPanel1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel>
Easy exit

You can change UpdateMode="Always" to UpdatePanel 2 to see the difference. If you do this, this panel will be updated in every message, whether it is full messages or messages coming from UpdatePanel1
Jupaol
source share