+1 integer and make it display?
I am using the following code,
vb Code:
Partial Class _Default
Inherits System.Web.UI.Page
Public count As Integer = 0
Protected Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
count += 1
Label1.Text = "You clicked the button " & count.ToString & " times!"
End Sub
End Class
however, all the page ever displays is "You clicked the button 1 times"
Re: +1 integer and make it display?
Thread moved from the 'ASP, VB Script' forum to the 'ASP.Net' forum
Re: +1 integer and make it display?
Re: +1 integer and make it display?
timers are designed for windows forms not asp.net web forms but you set the label.text as "You clicked the button..." so I'm confused over what you are trying to do.
lastly a public page scope variable will not persist over post backs, you need to store the value somewhere like viewstate to do this. Here is a example
Code:
sub btn_click(.......) handles button1.click
dim i as integer = 0
if isnothing(viewstate("counter")) then
'first time
i = 1
else
i = viewstate("counter") + 1
end if
viewstate("counter") = i
Label1.Text = "You clicked the button " & i & " times!"
end sub
Re: +1 integer and make it display?
TCarter,
Are you just starting out with ASP.Net? Have you done Windows Forms Development before?
You will find that although there are lots of similarities between ASP.Net and Windows, there are a few MAJOR differences, which Brin has touched on above. Once you get your head around these differences, you will find that a lot of stuff starts to make sense.
Let us know if you have any other questions.
Gary
Re: +1 integer and make it display?
sorry for the long delay,
Yes. I am new to ASP.Net, not new to forms.
I am going to be reading over your tutorials in your sig. Thanks for the insight.
Re: +1 integer and make it display?
Sounds good.
Let me know if you have any other questions.
Gary