Advertisement
DevUModerator

Untitled

Apr 13th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. namespace CS_ASP_025
  2. {
  3. public partial class Default : System.Web.UI.Page
  4. {
  5. protected void Page_Load(object sender, EventArgs e)
  6. {
  7. if(!Page.IsPostBack)
  8. {
  9. ViewState.Add("MyValue", "");
  10. }
  11. }
  12.  
  13. protected void addButton_Click(object sender, EventArgs e)
  14. {
  15. if (firstCheckBox.Checked &&
  16. secondCheckBox.Checked &&
  17. thirdCheckBox.Checked)
  18. {
  19. resultLabel.Text = "They're all checked!";
  20. }
  21.  
  22. else
  23. {
  24. // I set up NOW the ViewState to nothing, which is what I want to get in case that the if statement does not apply:
  25. ViewState["MyValue"] = "";
  26. // but I need a string to pass to the label so:
  27. string emptySolution = ViewState["MyValue"].ToString();
  28. resultLabel.Text = emptySolution;
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement