Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh ASP.NET page using custom event
    primarykey
    data
    text
    <p>I have created a List which generates a custom event based on Example 1 from this <a href="http://msdn.microsoft.com/en-us/library/aa645739%28v=vs.71%29.aspx" rel="nofollow">page</a>, and I need to update an aspx page whenever there are any new elements in the List.</p> <p>When I debug the application I can see that the value was updated, but nothing appears on the page.</p> <p><strong>ASPX</strong></p> <pre><code> &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"&gt; &lt;ContentTemplate&gt; &lt;fieldset&gt; &lt;legend&gt;UpdatePanel&lt;/legend&gt; &lt;asp:Label ID="xpto" runat="server" Text="zzzzzzzzzzzz"&gt;&lt;/asp:Label&gt; &lt;/fieldset&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p><strong>Code Behind</strong></p> <pre><code>MessageHandling.DashboardRequests.Changed += new EventHandler(ListChanged); ... ... ... private void ListChanged(object sender, EventArgs e) { DateTime dt = DateTime.Now; xpto.Text = dt.ToString(); } </code></pre> <p><em><strong>EDIT:</em></strong></p> <p>If I change the UpdateMode to Always and ListChanged method to:</p> <pre><code>private void ListChanged(object sender, EventArgs e) { DateTime dt = DateTime.Now; xpto.Text = dt.ToString(); UpdatePanel1.Update(); } </code></pre> <p>I get the following error:</p> <pre><code>The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' when UpdateMode is set to Conditional. </code></pre> <p>And if I set the UpdateMode to Conditional nothing happens again.</p> <p>If I create a timer and add this method:</p> <pre><code>protected void Timer1_Tick(object sender, EventArgs e) { DateTime dt = DateTime.Now; xpto.Text = dt.ToString(); } </code></pre> <p>the xpto is updated in the timer method correctly</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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