Wednesday, March 28, 2012

AJAX UpdatePanel Refresh != Browser Refresh

Hey everyone. I've got a problem, I have a page that I want the data and buttons to refresh every 30 seconds. When I click the button, the data is recorded into a database and the button(s) are disabled until the next interval comes up. An interval is 5 mins even though the data will refresh every 30 seconds. That means that when the button is pushed, it should be disabled until the 5 min interval is up.

The problem I'm having is that even though my whole page is in the Update Panel, my buttons DO NOT re-enable after that 5 min interval, but my data labels DO. I have an indicator that changes at each 5 min interval and it is working, but my buttons are still disabled. I can refresh the page and the buttons are enabled...another thing is that after I press the button and it's disabled, I can refresh the page and the buttons still stay disabled as thy should until the next 5 min interval.

Is the entire Page_Load called on the AJAX Update Panel refresh? It doesn't seem like it since my code that enables/disables my buttons is not being called. Any ideas?

What is the full page refresh doing that the AJAX Update panel is not? I would just do a normal page refresh, but that looks bad and I'm also using the collapsable panels and the normal page refresh call would collapse all the panels. That would make the use of them, well, useless.

try call the update function of the updatepanel

<asp:UpdatePanel ID="Test" ...

code behind ... Test.Update()

if not then use javascript to set the buttons back to disabled = false;


The data refreshes fine still, but the buttons don't "reset."

Baseically, I have a function that is called for each button that looks in the database to see if a log has been made for this record. If there is not a log, the button is enabled, if there is a log, the button is disabled until the next interval. For some reason, my functions that check my buttons are not being called when the update panel is updated each 30 seconds. The functionality when the button is clicked works fine, but the buttons never enable again unless I hit the refresh in the browser to refresh the entire page.

I hope someone else has some suggestions as to what might be going on. Thanks!


Ok, here's the answer of why my "AJAX UpdatePanel Refresh != Browser Refresh"...

In my old version of the page, I have the default value of my buttons set to enabled. Each time the page refreshes, the default value is seen. In the AJAX update panel, the default value is not seen and therefore my buttons were not resetting to the default. My functions were assuming these would be enabled unless the log was found.

I hope this helps someone that might have the same problems in the future.

No comments:

Post a Comment