UpdatePanelRenderModeCS.aspx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <script runat="server">
  4. protected int PostBackCount
  5. {
  6. get
  7. {
  8. return (int)(ViewState["PostBackCount"] ?? 0);
  9. }
  10. set
  11. {
  12. ViewState["PostBackCount"] = value;
  13. }
  14. }
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. if (IsPostBack)
  18. {
  19. PostBackCount++;
  20. }
  21. }
  22. </script>
  23. <html xmlns="http://www.w3.org/1999/xhtml">
  24. <head id="Head1" runat="server">
  25. <title>UpdatePanelRenderMode Example</title>
  26. </head>
  27. <body>
  28. <form id="form1" runat="server">
  29. <div>
  30. <asp:ScriptManager ID="ScriptManager1"
  31. runat="server" />
  32. The number of times you have clicked the button is
  33. <asp:UpdatePanel ID="UpdatePanel1"
  34. UpdateMode="Conditional"
  35. RenderMode="Inline"
  36. runat="server">
  37. <ContentTemplate>
  38. <%= PostBackCount.ToString() %>
  39. times. Every time you click the count is incremented. The panel
  40. containing the number of times you clicked is rendered in-line.
  41. <br />
  42. <asp:Button ID="Button1"
  43. Text="Increment"
  44. runat="server" />
  45. </ContentTemplate>
  46. </asp:UpdatePanel>
  47. </div>
  48. </form>
  49. </body>
  50. </html>