Incrementing variables in ASP.net on button click

后端 未结 7 1763
别跟我提以往
别跟我提以往 2021-01-24 16:25

I am new to asp.net. I am creating a ASP.net website using VB.net. So here\'s my problem

Dim myCounter as Integer = 0

Protected Sub Button1_Click(ByVal sender A         


        
相关标签:
7条回答
  • 2021-01-24 17:07

    your page class gets recreated on each request... so myCounter won't exist the next time.

    you can either

    • make myCounter static (not a great idea)
    • put it in the Application, Session, or Cache collection

    depends on what you're trying to do

    0 讨论(0)
提交回复
热议问题