Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 08, 2012 06:53 PM by gene7135
Apr 06, 2012 09:01 PM|LINK
Simple routine. Click a button to increase the time by 6 minutes.
Problem is it only works once unless I click a differnt button.
I thought I could check for PostBack but that did not fix.
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim varEndTime As Date
varEndTime = lblEndTime.Text
lblEndTime.Text = DateAdd(DateInterval.Minute, 6, varEndTime)
Apr 07, 2012 03:42 AM|LINK
Your variable varEndTIme is created brand new inside you button control so this must
only happen when you click the button, after it, the variable should be destroyed as the next click on Button1
will create a brand new variable with same name.
I am not sure what do you want to achieve here !
Are you trying to increase the time by 6 minutes when button is clicked, and repeat itself without the button being clicked again?
Apr 07, 2012 06:25 PM|LINK
I have a timestamp beling loaded into the label at page_load.
Each time the button is clicked,
For some reason the time will only increase once, unless I press a different button.
Apr 08, 2012 06:33 AM|LINK
The page load event will fire whenever you click a server side button or other control
So every time you click a button your timing thing will run in page load event, to prevent that
so that it runs only for the first time on the page load (and not on button clicks), you should
put that code inside page load, inside the if condition:
Apr 08, 2012 06:53 PM|LINK
I knew it was simple... Thanks!
yea.. I still don't have a lot of experience yet with ASP.net.