Incrementing variables in ASP.net on button click

后端 未结 7 1773
别跟我提以往
别跟我提以往 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 16:59

    Her's another method that doesn't use hidden field, viewstate, session or cache

    Probably not something very 'safe' but probably saves you some time.

    Assuming initial Label1.Text = 0

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Button1.Click
    
            Label1.Text = (Integer.Parse(Label1.Text) + 1).ToString()
    
    end Sub
    

提交回复
热议问题