Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all I would like to recall the use of <code>UpdateMode</code></p> <ul> <li><p><code>Always</code> The panel will update its content <strong>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 updated</strong></p></li> <li><p><code>Conditional</code> The content of the panel will only be updated when different conditions are met:</p> <ul> <li><p>By default the events triggered by its child objects will trigger an update, you can change this behavior setting <code>ChildrenAsTriggers="false"</code></p></li> <li><p>When you declare a trigger in the <code>Triggers</code> section of the <code>UpdatePanel</code></p></li> <li><p>When you explicitly call the <code>UpdatePanel.Update()</code> method</p></li> <li><p>Full page posts will trigger the update</p></li> </ul></li> </ul> <p>The following code does the following:</p> <ul> <li><p>Each UpdatePanel is updated when its child controls raise an event</p></li> <li><p>The UpdatePanel 1 named: <code>up1</code> will be updated <strong>only</strong> when its child controls raise an event</p></li> <li><p>The UpdatePanel 2 named <code>up2</code> will be updated when its child controls raise an event</p></li> <li><p>The UpdatePanel 2 named <code>up2</code> will also be updated when the triggers defined are fired, in this case, when the <code>DropDownList</code> named <code>ddl1OnPanel1</code> on the UpdatePanel 1 fires its <code>SelectedIndexChanged</code></p></li> <li><p>The UpdatePanel 2 named <code>up2</code> will also be updated when the <code>DropDownList</code> named <code>ddl2OnPanel1</code> on the UpdatePanel 1 raises its <code>SelectedIndexChanged</code>, because in code it explicitly calls: <code>this.up2.Update();</code></p></li> </ul> <p><em>I think that tweaking this code, you could achieve your desired goal, just copy paste it on a new page and run it</em></p> <h3>Check the following code (see how the labels showing the date are affected in different ways depending on the events raised):</h3> <h3>Code Behind</h3> <pre><code> 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(); } </code></pre> <h3>ASPX</h3> <pre><code> &lt;asp:ScriptManager runat="server" ID="scriptManager" /&gt; &lt;asp:Button Text="Full Post" runat="server" /&gt; &lt;br /&gt; &lt;asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;asp:DropDownList runat="server" ID="ddl1OnPanel1" AutoPostBack="true" OnSelectedIndexChanged="ddl1OnPanel1_SelectedIndexChanged"&gt; &lt;asp:ListItem Text="text1" /&gt; &lt;asp:ListItem Text="text2" /&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;asp:DropDownList runat="server" ID="ddl2OnPanel1" AutoPostBack="true" OnSelectedIndexChanged="ddl2OnPanel1_SelectedIndexChanged"&gt; &lt;asp:ListItem Text="text3" /&gt; &lt;asp:ListItem Text="text4" /&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;asp:Label runat="server" ID="lblMessageOnPanel1" /&gt; &lt;br /&gt; &lt;asp:Button ID="Button1" Text="text" runat="server" /&gt; &lt;br /&gt; On every post on Panel 1: &lt;%:DateTime.Now %&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:UpdatePanel runat="server" ID="up2" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;asp:Calendar ID="calendarOnPanel2" runat="server" &gt; &lt;DayHeaderStyle CssClass="dayheaderStyle" /&gt; &lt;NextPrevStyle /&gt; &lt;OtherMonthDayStyle BackColor="#ffffff" /&gt; &lt;SelectedDayStyle /&gt; &lt;TitleStyle CssClass="titleStyle" /&gt; &lt;TodayDayStyle BackColor="#ffffa0" ForeColor="#6699cc" /&gt; &lt;WeekendDayStyle /&gt; &lt;DayStyle CssClass="dayStyle" /&gt; &lt;/asp:Calendar&gt; &lt;br /&gt; &lt;asp:Label ID="lblMessageOnPanel2" runat="server" /&gt; &lt;br /&gt; On every post On Panel 2: &lt;%:DateTime.Now %&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="ddl1OnPanel1" EventName="SelectedIndexChanged" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <h3>Simple Output</h3> <p><img src="https://i.stack.imgur.com/zW8ac.png" alt="enter image description here"></p> <p>You could change the <code>UpdateMode="Always"</code> 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</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload