48025

UpdatePanel Timer causes all panels to update

Question:

I have an ASP.NET web form with several UpdatePanels and I would like to have a timer that triggers only one of these UpdatePanels to update. I then want a separate UpdatePanel to update on the OnSelectedIndexChanged event of a DropDownList. The code I have will update the timer-triggered panel just fine, but when I change the index, the drop down-triggered panel will wait until the next timer tick to update. How can I have the drop down-triggered panel update instantaneously? Code below.

C#:

public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Timer1_Tick(object sender, EventArgs e) { Label1.Text = "UpdatePanel1 refreshed at: " + DateTime.Now.ToLongTimeString(); } protected void dropDown_indexChange(object sender, EventArgs e) { Label2.Text = "UpdatePanel2 refreshed at: " + DateTime.Now.ToLongTimeString(); //UpdatePanel2.Update(); -- Didn't help } }

ASP:

<form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="not updated yet"></asp:Label> <asp:Timer ID="Timer1" runat="server" Interval="3000" ontick="Timer1_Tick"></asp:Timer> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" Text="also not updated yet"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <br /> <br /> <asp:DropDownList OnSelectedIndexChanged="dropDown_indexChange" ID="DropDownList1" runat="server"> <asp:ListItem>This</asp:ListItem> <asp:ListItem>That</asp:ListItem> <asp:ListItem>The Other</asp:ListItem> </asp:DropDownList> </div> </form>

Answer1:

Move your DropDownList into an UpdatePanel and set .AutoPostBack = true on it.

Recommend

  • setTimeout function not working when looping through markers on Gmaps API
  • QT exec() command crash
  • Highlight cell conditional on another cell being clicked
  • How to reduce QT program start-up time when using a DLL
  • Restricted profiles settings not being remembered
  • symfony 2 phpunit - how to untick checkbox in form field
  • ScheduledThreadPoolExecutor only “ticking” once
  • Set User Control's default event
  • jQuery ajax security
  • How to move axis labels automatically in rgl R
  • Azure table query partial partitionkey guid match
  • Implement JwtBearer Authentication in NSwag SwaggerUi
  • Implementing “partial void” in VB
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Spring Data JPA custom method causing PropertyReferenceException
  • Change JButton Shape while respecting Look And Feel
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Can I display google adwords (AdView) in javafx on android
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • jQuery tmpl and DataLink beta
  • Is there a mandatory requirement to switch app.yaml?
  • Cannot Parse HTML Data Using Android / JSOUP
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • Acquiring multiple attributes from .xml file in c#
  • JTable with a ScrollPane misbehaving
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Java static initializers and reflection
  • How does Linux kernel interrupt the application?
  • How can I remove ASP.NET Designer.cs files?
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?