I appreciate your help with this. I am creating a very simple aspx page with 1 label and 1 button. I am trying to update the label every 200 ms by adding 1 to the previous value. when I run the program the label stops at 1:
PublicClassWebForm1InheritsSystem.Web.UI.PageProtectedSubPage_Load(ByVal sender AsObject,ByVal e AsSystem.EventArgs)HandlesMe.LoadEndSubDim c =0ProtectedSubTimer1_Tick(sender AsObject, e AsEventArgs)HandlesTimer1.Tick
c = c +1Label1.Text= c
EndSubProtectedSubButton1_Click(sender AsObject, e AsEventArgs)HandlesButton1.ClickTimer1.Interval=200Timer1.Enabled=TrueEndSubEndClass
Thank you for your reply. I agree with you. I changed the request to 1 request every 5 seconds. It is still not working. I also checked the link and to be honest, it wasn't different compared to my code. When I press the button, the Label counts 1 and then
stops, it doesn't update from there onward.
Thank you for your reply. I agree with you. I changed the request to 1 request every 5 seconds. It is still not working. I also checked the link and to be honest, it wasn't different compared to my code. When I press the button, the Label counts 1 and then
stops, it doesn't update from there onward.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Dim c = 0
Protected Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Label1.Text <> "Label" Then
c = Convert.ToInt32(Label1.Text)
End If
c = c + 1
Label1.Text = c
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Result:
Rest Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Thank you for your reply! I managed to make it work on my localhost but once uploaded to the server which allows AJAX it just doesnt work at all when I click the button. It looks like the timer doesn’t appear to be working. I am wondering if I am missing something
in the web.config file . On Localhost it works perfectly!
Something simple I am missing there that is making it not work on the server.
Thank you for your reply! I managed to make it work on my localhost but once uploaded to the server which allows AJAX it just doesnt work at all when I click the button. It looks like the timer doesn’t appear to be working. I am wondering if I am missing something
in the web.config file . On Localhost it works perfectly!
According to your description, it is too hard directly find out the reason why it doesn't work well on the server,
Do you have any error message?
I suggest you could use f12 developtool's network tag to see how the ajax works and check the error message.
Besides, since this issue is not related with your first thread, I suggest you could firstly mark the helpful reply as answer and start a new thread to talk about your new issue.
This will help other people who faces the same issue.
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
2 Points
8 Posts
Using Timer and Update Panel to update a label
Jun 16, 2018 03:20 PM|raefkobeissi|LINK
Hi
I appreciate your help with this. I am creating a very simple aspx page with 1 label and 1 button. I am trying to update the label every 200 ms by adding 1 to the previous value. when I run the program the label stops at 1:
Can you please tell me what I am doing wrong?
Cheers
</div> </div>
All-Star
53691 Points
24028 Posts
Re: Using Timer and Update Panel to update a label
Jun 16, 2018 04:00 PM|mgebhard|LINK
https://stackoverflow.com/questions/3523470/timer-in-updatepanel
Member
2 Points
8 Posts
Re: Using Timer and Update Panel to update a label
Jun 16, 2018 04:07 PM|raefkobeissi|LINK
Thank you for your reply. I agree with you. I changed the request to 1 request every 5 seconds. It is still not working. I also checked the link and to be honest, it wasn't different compared to my code. When I press the button, the Label counts 1 and then stops, it doesn't update from there onward.
Your help is much appreciated.
All-Star
53691 Points
24028 Posts
Re: Using Timer and Update Panel to update a label
Jun 16, 2018 05:59 PM|mgebhard|LINK
Perhaps this tutorial is more direct.
https://msdn.microsoft.com/en-us/library/bb386404.aspx
Star
9831 Points
3120 Posts
Re: Using Timer and Update Panel to update a label
Jun 19, 2018 09:14 AM|Brando ZWZ|LINK
Hi raefkobeissi,
As far as I know, if the timer trigger the tick event, the server will run all the code inside the TimerWithUpdatePanel page code-behind.
So it will reset the c to 0 and plus 1 again. You will find it always show 1.
I suggest you could set a breakpoint at the page load event to see how the page works. This is related with the asp.net web form page life.
I suggest you could consider directly get the current textbox value and plus 1.
It will work well.
More details, you could refer to below codes:
ASPX:
Code-behind:
Result:
Rest Regards,
Brando
Member
2 Points
8 Posts
Re: Using Timer and Update Panel to update a label
Jun 19, 2018 10:48 AM|raefkobeissi|LINK
Something simple I am missing there that is making it not work on the server.
Star
9831 Points
3120 Posts
Re: Using Timer and Update Panel to update a label
Jun 19, 2018 12:49 PM|Brando ZWZ|LINK
Hi raefkobeissi,
According to your description, it is too hard directly find out the reason why it doesn't work well on the server,
Do you have any error message?
I suggest you could use f12 developtool's network tag to see how the ajax works and check the error message.
Besides, since this issue is not related with your first thread, I suggest you could firstly mark the helpful reply as answer and start a new thread to talk about your new issue.
This will help other people who faces the same issue.
Best Regards,
Brando
Member
2 Points
8 Posts
Re: Using Timer and Update Panel to update a label
Jun 19, 2018 01:14 PM|raefkobeissi|LINK
Thank you, I created a new thread as advised:
https://forums.asp.net/p/2142524/6213057.aspx?p=True&t=636649855446131352