By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Need to be able for buttons to keep track of each other

P: n/a
bob
I am just getting into web programming. I am using VB ASP.NET. I have
multiple buttons on my form.
When a person clicks on one of imgagebuttons, I want a accumulated counter
for each time a button is clicked, and when 2 different imagebuttons are
clicked, I want them compared to see if the images are the same, how do I do
this? I tried making the variables public, but I think I am having problems
with viewstate in which I am not using besides the property being true.

TIA
..
Here the code behind one of the buttons:

ncount += 1 'this is suppose to count how many buttons are pushed.

If ncount < 3 Then

ImageButton2.ImageUrl = newimage

Select Case ncount

Case 1

b(1) = ImageButton2.ImageUrl

Case 2

b(2) = ImageButton2.ImageUrl

ncount = 0 ' reset the count because only 1 or 2 buttons_

'be pushed at 1 time.

If b(1) = b(2) Then

'Messagebox("Correct")

correct += 1

lblNumberCorrect.Text = Str(correct)

lblifCorrect.Text = "Correct"

Else

incorrect += 1

lblNumberIncorrect.text = Str(incorrect)

lblifcorrect.Text = "InCorrect"

End If

ncount = 0

End Select

End If


Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Pages are stateless, they create for each request and destroyed when
request ended (HTML send to client). This mean that you need to preserve
your data between pages calls (every click on server control button
cause postback that generate request to the server).

You can preserve your data on the server using Session or on the client
by using ViewState. You can add items to view state and they will be
send to the client and back to server in every postback.

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.