UpdatePanelExample1CS.aspx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <script runat="server">
  5. void DropDownSelection_Change(Object sender, EventArgs e)
  6. {
  7. Calendar1.DayStyle.BackColor =
  8. System.Drawing.Color.FromName(ColorList.SelectedItem.Value);
  9. }
  10. protected void Calendar1_SelectionChanged(object sender, EventArgs e)
  11. {
  12. SelectedDate.Text =
  13. Calendar1.SelectedDate.ToString();
  14. }
  15. </script>
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head id="Head1" runat="server">
  18. <title>UpdatePanel Example</title>
  19. </head>
  20. <body>
  21. <form id="form1" runat="server">
  22. <div>
  23. <asp:ScriptManager ID="ScriptManager1"
  24. runat="server" />
  25. <asp:UpdatePanel ID="UpdatePanel1"
  26. runat="server">
  27. <ContentTemplate>
  28. <asp:Calendar ID="Calendar1"
  29. ShowTitle="True"
  30. OnSelectionChanged="Calendar1_SelectionChanged"
  31. runat="server" />
  32. <div>
  33. Background:
  34. <br />
  35. <asp:DropDownList ID="ColorList"
  36. AutoPostBack="True"
  37. OnSelectedIndexChanged="DropDownSelection_Change"
  38. runat="server">
  39. <asp:ListItem Selected="True" Value="White">
  40. White </asp:ListItem>
  41. <asp:ListItem Value="Silver">
  42. Silver </asp:ListItem>
  43. <asp:ListItem Value="DarkGray">
  44. Dark Gray </asp:ListItem>
  45. <asp:ListItem Value="Khaki">
  46. Khaki </asp:ListItem>
  47. <asp:ListItem Value="DarkKhaki"> D
  48. ark Khaki </asp:ListItem>
  49. </asp:DropDownList>
  50. </div>
  51. <br />
  52. Selected date:
  53. <asp:Label ID="SelectedDate"
  54. runat="server">None.</asp:Label>
  55. </ContentTemplate>
  56. </asp:UpdatePanel>
  57. <br />
  58. </div>
  59. </form>
  60. </body>
  61. </html>