code_junkie

Hide/Show controls with AJAX

Nov 13th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. ScriptManager1.RegisterAsyncPostBackControl(Button1);
  4.  
  5.  
  6. if (!IsPostBack)
  7. {
  8.  
  9. Visibility = true;
  10. }
  11.  
  12. UpdatePanel_1.Visible = !Visibility;
  13. UpdatePanel_2.Visible = Visibility;
  14.  
  15. Visibility = !Visibility;
  16. }
  17.  
  18.  
  19. protected void Button1_Click(object sender, EventArgs e)
  20. {
  21. if (Panel1.Visible)
  22. UpdatePanel_1.Update();
  23. }
  24.  
  25. protected bool Visibility
  26. {
  27. get
  28. {
  29. return (bool)(ViewState["Visibility"] ?? true);
  30. }
  31. set
  32. {
  33. ViewState["Visibility"] = value;
  34. }
  35. }
Add Comment
Please, Sign In to add comment