UpdatePanelHowTo2CS.aspx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <%@ Page Language="C#" %>
  2. <%@ Register Src="Controls/WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <script runat="server">
  5. protected void WebUserControl1_Click(object sender, EventArgs e)
  6. {
  7. if (WebUserControl1.Range != -1)
  8. Label1.Text = "You selected " +
  9. WebUserControl1.Range.ToString() +
  10. " day(s).";
  11. CalendarPanel.Visible = false;
  12. }
  13. protected void ShowCalendar(object sender, EventArgs e)
  14. {
  15. CalendarPanel.Visible = true;
  16. }
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. if (!IsPostBack)
  20. {
  21. CalendarPanel.Visible = false;
  22. Label1.Text = "You have not selected any days.";
  23. }
  24. }
  25. </script>
  26. <html xmlns="http://www.w3.org/1999/xhtml">
  27. <head runat="server">
  28. <title>UpdatePanel UserControl Example</title>
  29. <style type="text/css">
  30. div.CalendarPanel
  31. {
  32. background-color: white;
  33. text-align: center;
  34. position: absolute;
  35. top: 30px;
  36. left: 160px;
  37. width: 300px;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <form id="form1" runat="server">
  43. <div>
  44. <!-- This example is not meant to be shown to users as is.
  45. it is providing snippets for conceptual topic. -->
  46. <asp:ScriptManager ID="TheScriptManager"
  47. runat="server" />
  48. <asp:UpdatePanel ID="UpdatePanel1"
  49. UpdateMode="Conditional"
  50. runat="server">
  51. <ContentTemplate>
  52. </ContentTemplate>
  53. </asp:UpdatePanel>
  54. <asp:LinkButton ID="ShowCalendarLinkButton"
  55. Text="Choose a number of days"
  56. OnClick="ShowCalendar"
  57. runat="server" />
  58. <asp:Panel ID="CalendarPanel"
  59. GroupingText="Choose a Range"
  60. CssClass="CalendarPanel"
  61. runat="server">
  62. </asp:Panel>
  63. <uc1:WebUserControl ID="WebUserControl1"
  64. OnInnerClick="WebUserControl1_Click"
  65. runat="server">
  66. </uc1:WebUserControl>
  67. <br />
  68. <asp:Label ID="Label1"
  69. runat="server"/>
  70. </div>
  71. </form>
  72. </body>
  73. </html>