I just started playing around with ASP.Net, after learning a little bit of visual basic.
I'm simply trying to display a counter in a label, and after a button is pressed the counter increments by 1. For some reason I cannot seem to get this seemingly simple task to work.
At the top of my aspx.vb code I declared a module level variable and set its property:
Public myCounter As Integer
Public Property counter() As Integer
Get
Return myCounter
End Get
Set(ByVal value As Integer)
myCounter = value
End Set
End Property
Towards the middle I have the button event, where the counter is SUPPOSED to increment and display in a label:
rotected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Increment counter variable by 1
counter = counter + 1
'Show new counter in label
lblTest.Text = counter.ToString
End Sub
The problem is that no matter how many times I click the button, the counter always displays "1"... What am I doing wrong?
I'm simply trying to display a counter in a label, and after a button is pressed the counter increments by 1. For some reason I cannot seem to get this seemingly simple task to work.
At the top of my aspx.vb code I declared a module level variable and set its property:
Public myCounter As Integer
Public Property counter() As Integer
Get
Return myCounter
End Get
Set(ByVal value As Integer)
myCounter = value
End Set
End Property
Towards the middle I have the button event, where the counter is SUPPOSED to increment and display in a label:
rotected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Increment counter variable by 1
counter = counter + 1
'Show new counter in label
lblTest.Text = counter.ToString
End Sub
The problem is that no matter how many times I click the button, the counter always displays "1"... What am I doing wrong?