Hi,
You won't be able to do this directly from server side code. Because the client side code of the ProgressBar needs to be aware that a server side task is running, the RunTask event can only be triggered from client side. So what you need to do is actually a two step process:
---- Normal Button Click event flow begin -----
1. The Button is clicked and server side Button_Click event is triggered;
2. Your code in Button_Click event handler updates database;
3. The page is reloaded;
---- Normal Button Click event flow end -----
---- ProgressBar RunTask event flow ----
4. Calling progressBar.startTask from client side;
5. Server side ProgressBar_RunTask event is triggered;
The key here is you need to connect step 3 and step 4. This can usually be done by rendering some JavaScript code in step 2. For example, you can have a Label control in your Form and then in step 2 you can do something like this:
Code: C#
Label1.Text = "<script>progressBar.startTask()</script>";
This way when this code is rendered to the client through step 3, it will call startTask and enter step 4.
If your ProgressBar_RunTask handler depends on values in previous steps (such as a record_id you just inserted in step 2), then you may want to use session variable to pass that value as there is no way for you to pass such value directly between the first round trip (step 1 to step 3) and the second round trip (step 4 and step 5).
Hope this helps. Please feel free to let us know if you still have any questions.
Thanks!