WizardWithoutUpdatePanelCS.aspx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
  6. {
  7. // Business logic to determine if performance is available.
  8. // For demonstration we are not allowing matinee tickets.
  9. args.IsValid = false;
  10. if (DropDownList1.SelectedIndex > 0)
  11. {
  12. args.IsValid = true;
  13. }
  14. }
  15. protected void Calendar1_SelectionChanged(object sender, EventArgs e)
  16. {
  17. TextBox3.Text = Calendar1.SelectedDate.ToShortDateString();
  18. }
  19. protected void Page_Load(object sender, EventArgs e)
  20. {
  21. CompareValidator1.ValueToCompare = DateTime.Today.ToShortDateString();
  22. }
  23. </script>
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head runat="server">
  26. <title>Wizard Without UpdatePanel</title>
  27. </head>
  28. <body>
  29. <form id="form1" runat="server">
  30. <div>
  31. <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" BackColor="#EFF3FB"
  32. BorderColor="#B5C7DE" BorderWidth="1px" Font-Names="Verdana"
  33. Font-Size="0.8em" Width="460px">
  34. <StepStyle Font-Size="0.8em" ForeColor="#333333" />
  35. <SideBarStyle BackColor="#507CD1" Font-Size="0.9em" VerticalAlign="Top" />
  36. <NavigationButtonStyle BackColor="White" BorderColor="#507CD1"
  37. BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
  38. Font-Size="0.8em" ForeColor="#284E98" />
  39. <WizardSteps>
  40. <asp:WizardStep ID="WizardStep1" runat="server" StepType="Start" Title="Specify Tickets">
  41. <asp:Label ID="Label1" runat="server" Text="Enter a number 1 to 10:"></asp:Label>
  42. <asp:TextBox ID="TextBox1" runat="server" Width="50px"></asp:TextBox>
  43. <br />
  44. <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1"
  45. Display="None" ErrorMessage="Incorrect number of tickets." MaximumValue="10"
  46. MinimumValue="1" Type="Integer"></asp:RangeValidator>
  47. <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
  48. ControlToValidate="TextBox1" Display="None" ErrorMessage="Enter a number of tickets." ></asp:RequiredFieldValidator><br />
  49. <asp:Label ID="Label2" runat="server" Text="Enter an email address:"></asp:Label>
  50. <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
  51. <br />
  52. <asp:RegularExpressionValidator ID="RegularExpressionValidator1"
  53. runat="server" ControlToValidate="TextBox2" Display="None"
  54. ErrorMessage="The email was not correctly formatted."
  55. ValidationExpression="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
  56. ></asp:RegularExpressionValidator>
  57. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
  58. ControlToValidate="TextBox2" Display="None" ErrorMessage="Email is required."
  59. ></asp:RequiredFieldValidator><br />
  60. <asp:ValidationSummary ID="Step1ValidationSummary"
  61. runat="server" />
  62. </asp:WizardStep>
  63. <asp:WizardStep ID="WizardStep2" runat="server" Title="Select A Date" StepType="Finish">
  64. <div style="text-align: center">
  65. <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged">
  66. </asp:Calendar>
  67. </div>
  68. <br />
  69. <asp:Label ID="Label3" runat="server" Text="Choose a date to attend:"></asp:Label>
  70. <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
  71. <br />
  72. <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox3"
  73. ErrorMessage="Pick a date in the future." Operator="GreaterThanEqual"
  74. Type="Date" Display="None"></asp:CompareValidator>
  75. <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
  76. ControlToValidate="TextBox3" Display="None" ErrorMessage="Date is required."></asp:RequiredFieldValidator><br />
  77. Choose a performance:
  78. <asp:DropDownList ID="DropDownList1" runat="server">
  79. <asp:ListItem>matinee</asp:ListItem>
  80. <asp:ListItem>early evening</asp:ListItem>
  81. <asp:ListItem>late evening</asp:ListItem>
  82. </asp:DropDownList>
  83. <br />
  84. <asp:CustomValidator ID="CustomValidator1" Display="None" runat="server" ControlToValidate="DropDownList1"
  85. ErrorMessage="That performance is not available." OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator><br />
  86. <asp:ValidationSummary ID="ValidationSummary2"
  87. runat="server" />
  88. </asp:WizardStep>
  89. <asp:WizardStep ID="WizardStep3" runat="server" StepType="Complete" Title="See You There!">
  90. Your tickets will be sent in email.
  91. </asp:WizardStep>
  92. </WizardSteps>
  93. <SideBarButtonStyle BackColor="#507CD1" Font-Names="Verdana"
  94. ForeColor="White" />
  95. <HeaderStyle BackColor="#284E98" BorderColor="#EFF3FB" BorderStyle="Solid"
  96. BorderWidth="2px" Font-Bold="True" Font-Size="0.9em" ForeColor="White"
  97. HorizontalAlign="Center" />
  98. <HeaderTemplate>
  99. Order Your Complimentary Tickets
  100. </HeaderTemplate>
  101. </asp:Wizard>
  102. </div>
  103. </form>
  104. </body>
  105. </html>