Hi all,
Could someone help me to find a way to make the flag value which has been set in the btn_click methods to be used right in postback? (please see pseudo code below)
What I want is, when I click btn2, flag is set to be false, so in postback, it will execute:
if flag=false then do something else
However, what I found is: when btn2 is clicked, postback occurs and uses the old value of flag (=true), then it will set flag=false after the postback. As a result, if the next postback occurs, it will take flag as false. All I want is flag=false to be taken right in the first postback before it does a postback. Any hints? Thanks in advance.
Private Sub Page_Load
If Not (Page.IsPostBack) Then
'flag is a static variable: its value
'is retained between postbacks
flag = true
else
if flag = true then
'do something
else
'do something else
end if
end if
end sub
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
flag=true
End Sub
Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
flag=false
End Sub
Could someone help me to find a way to make the flag value which has been set in the btn_click methods to be used right in postback? (please see pseudo code below)
What I want is, when I click btn2, flag is set to be false, so in postback, it will execute:
if flag=false then do something else
However, what I found is: when btn2 is clicked, postback occurs and uses the old value of flag (=true), then it will set flag=false after the postback. As a result, if the next postback occurs, it will take flag as false. All I want is flag=false to be taken right in the first postback before it does a postback. Any hints? Thanks in advance.
Private Sub Page_Load
If Not (Page.IsPostBack) Then
'flag is a static variable: its value
'is retained between postbacks
flag = true
else
if flag = true then
'do something
else
'do something else
end if
end if
end sub
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
flag=true
End Sub
Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
flag=false
End Sub