I have two update panels on a page. And I want to update both of them conditions at different-2 conditions. But I don’t know why this is not happening. I have specified triggers for both but not helpful, below is my code.
Please let me know Where I am wrong.
Actually there are three dropdown lists in first update panel when their selectedindexchange is fired then the second update panel’s content also updates.
<asp:UpdatePanel ID="upSearch" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<div style="float: left; width: auto;">
<asp:DropDownList ID="ddlLocation" runat="server" Width="206px" DataTextField="LocationName"
DataValueField="Locationid" AutoPostBack="true" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="ddlArea" runat="server" Width="200px" DataTextField="AreaName"
DataValueField="Areaid" AutoPostBack="true" OnSelectedIndexChanged="ddlArea_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="ddlRoom" runat="server" Width="200px" DataTextField="RoomName"
DataValueField="Roomid">
</asp:DropDownList>
</div>
<div style="float: left; width: 80px;">
<asp:Button ID="btnSearch" runat="server" Text="Search" ValidationGroup="vgSearch"
CssClass="bluebtn" UseSubmitBehavior="false" OnClick="btnSearch_Click" />
</div>
<div style="float: left; width: 99%; padding: 5px 0px;">
</div>
</ContentTemplate>
</asp:UpdatePanel>
And the second one is as follow:-
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:Calendar ID="calSchedule" runat="server" NextPrevFormat="FullMonth" OnDayRender="calSchedule_DayRender"
OnVisibleMonthChanged="calSchedule_VisibleMonthChanged">
<DayHeaderStyle CssClass="dayheaderStyle" />
<NextPrevStyle />
<OtherMonthDayStyle BackColor="#ffffff" />
<SelectedDayStyle />
<TitleStyle CssClass="titleStyle" />
<TodayDayStyle BackColor="#ffffa0" ForeColor="#6699cc" />
<WeekendDayStyle />
<DayStyle CssClass="dayStyle" />
</asp:Calendar>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
First of all I would like to recall the use of
UpdateModeAlwaysThe panel will update its content on every post on the page, they can be partial rendering posts or full posts, in both cases the content of the panel will be updatedConditionalThe content of the panel will only be updated when different conditions are met:By default the events triggered by its child objects will trigger an update, you can change this behavior setting
ChildrenAsTriggers="false"When you declare a trigger in the
Triggerssection of theUpdatePanelWhen you explicitly call the
UpdatePanel.Update()methodFull page posts will trigger the update
The following code does the following:
Each UpdatePanel is updated when its child controls raise an event
The UpdatePanel 1 named:
up1will be updated only when its child controls raise an eventThe UpdatePanel 2 named
up2will be updated when its child controls raise an eventThe UpdatePanel 2 named
up2will also be updated when the triggers defined are fired, in this case, when theDropDownListnamedddl1OnPanel1on the UpdatePanel 1 fires itsSelectedIndexChangedThe UpdatePanel 2 named
up2will also be updated when theDropDownListnamedddl2OnPanel1on the UpdatePanel 1 raises itsSelectedIndexChanged, because in code it explicitly calls:this.up2.Update();I think that tweaking this code, you could achieve your desired goal, just copy paste it on a new page and run it
Check the following code (see how the labels showing the date are affected in different ways depending on the events raised):
Code Behind
ASPX
Simple Output
You could change the
UpdateMode="Always"on the UpdatePanel 2, to see the difference, if you do it, this panel will be updated on every post, either full posts or posts coming from the UpdatePanel1