triggering label to appear after firing 4 buttons onclick events
I have an algorithm but don't know if this is the开发者_运维技巧 correct way. like mentioned, i would like my label to appear after the user clicks on 4 different buttons, each button with auto post back.
if(button 1 click && button 2 click && button 3 click && button 4 click)
label1.visible = true;
what should be the codes inside the if statement?
you can use ViewState for this. on each button click event update the view state with the button flag. for example for button 1
if(ViewState["MyButtonState"]==null)
ViewState["MyButtonState"]=1;
else
ViewState["MyButtonState"]=((int)ViewState["MyButtonState"]) | 1;
you can use flag enumeration for this as well which is better approach. for button 1-4 use 1,2,4,8 and finally in the if statement
if(((int)ViewState["MyButtonState"])==0x0000000F)
label1.Visible=true;
精彩评论