I have this UpdatePanel I want to use in my website. Basicly the idea is that a user clicks on a link and start a service on the server that will change a database.
So what I want to write is a method that wil return true or false if the database is updated. The method should run on timed intervals. If the database has been updated it will return true and that should trigger the UpdatePanel to update.
I know you can add triggers through controls. But is it possible to do so through code as well? The idea is that if the user stays on the page after starting the action he will see the result appear when the method returns true. If the user leaves the page he of course sees nothing.
If this is not the right to use this then please say so.
Any comment will be appreciated! Kind regards, Floris
I suggest you use a asp:Timer
you can place this timer inside or outside of your update panel. if you put it inside the update panel you don't have to handle the trigger yourself. every post back inside an upatepanel will become Async. but if you put it out side, you have to assign the trigger.
here are sample codes for your aspx:
while it's easier to put it inside the update panel:
now on the c# side, you must write the event handler method like this one:
in this example, after 5 seconds a tadaaaah will appear on the screen. you should update your panel in this event handler. i.e. set a Label's text. I hope I got you problem right.
you can put a check for wheather the value is updated in database or not and then if updated you should put below code in if section
if(condition) {