フォーム イン ASP.NET を作成しました。コードを以下に示します。
<form id="AddSchool" method="post" runat="server">
<span class="failureNotification">
<asp:Literal ID="ErrorMessage" runat="server" ></asp:Literal>
</span>
<asp:ValidationSummary ID="AddSchoolValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="AddSchoolValidationGroup"/>
<asp:Label ID="SchoolNameLabel" runat="server" Text="School Name " AssociatedControlID="SchoolName"></asp:Label>
<asp:TextBox ID="SchoolName" runat="server" Height="16px" Width="337px" CssClass="textEntry"></asp:TextBox>
<asp:Label ID="Label15" runat="server" Font-Size="Larger" ForeColor="Red" Text="*"></asp:Label>
<asp:RequiredFieldValidator ID="SchoolNameRequired" ControlToValidate="SchoolName" CssClass="failureNotification" runat="server" ErrorMessage="School Name is Required" ToolTip="School Name is Required"
ValidationGroup="AddSchoolValidationGroup"></asp:RequiredFieldValidator>
<asp:Label ID="StreetAddressLabel" runat="server" Text="Street Address " AssociatedControlID="StreetAddress"></asp:Label>
<asp:TextBox ID="StreetAddress" runat="server" Height="16px" Width="338px" CssClass="textEntry"></asp:TextBox>
<asp:Label ID="Label16" runat="server" Font-Size="Larger" ForeColor="Red" Text="*"></asp:Label>
<asp:RequiredFieldValidator ID="StreetAddressRequired" ControlToValidate="StreetAddress" CssClass="failureNotification" runat="server"
ErrorMessage="Street Address is Required" ToolTip="Street Address is Required" ValidationGroup="AddSchoolValidationGroup"></asp:RequiredFieldValidator>
<asp:Label ID="CityLabel" runat="server" Text="City " AssociatedControlID="City" ></asp:Label>
<asp:TextBox ID="City" runat="server" Height="16px" Width="340px" style="margin-left: 0px" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="CityRequired" runat="server" ControlToValidate="City" CssClass="failureNotification"
ErrorMessage="City is Required" ToolTip="City is Required" ValidationGroup="AddSchoolValidationGroup"></asp:RequiredFieldValidator>
<asp:Label ID="StateLabel" runat="server" Text="State " AssociatedControlID="StateList"></asp:Label>
<asp:DropDownList ID="StateList" runat="server" Height="25px" Width="119px" DataSourceID="SqlDataSource1" DataTextField="StateName" DataValueField="StateName" CssClass="textEntry">
<asp:ListItem>Select A State</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label17" runat="server" Font-Size="Larger" ForeColor="Red" Text="*"></asp:Label>
<asp:RequiredFieldValidator ID="StateRequired" runat="server" Display="Dynamic" ControlToValidate="StateList" CssClass="failureNotification"
ErrorMessage="A State is Required" ToolTip="A State is Required" ValidationGroup="AddSchoolValidationGroup"></asp:RequiredFieldValidator>
<asp:Label ID="ZipLabel" runat="server" Text="Zip Code :" AssociatedControlID="ZipCode"></asp:Label>
<asp:TextBox ID="ZipCode" runat="server" Width="139px" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="ZipCodeRequired" runat="server" ControlToValidate="ZipCode" CssClass="failureNotification"
ErrorMessage="Zip Code is Required" ToolTip="Zip Code is Required" ValidationGroup="AddSchoolValidationGroup"></asp:RequiredFieldValidator>
<asp:Label ID="EmailLabel" runat="server" Text="Email Address" AssociatedControlID="Email"></asp:Label>:
<asp:TextBox ID="Email" runat="server" Width="304px" Height="16px" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" CssClass="failureNotification"
ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="AddSchoolValidationGroup">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="EmailFormat" runat="server" ControlToValidate="Email" CssClass="failureNotification"
ErrorMessage="The email address entered does not appear to be valid." ValidationGroup="AddSchoolValidationGroup"
ValidationExpression="([A-Z]|[a-z]|[0-9])+[@]([A-Z]|[a-z]|[0-9])+\.([A-Z]|[a-z]){2,6}" Display="Dynamic">*</asp:RegularExpressionValidator>
<asp:Label ID="ConfirmEmailLabel" runat="server" Text="Confirm Email Address " AssociatedControlID="ConfirmEmail"></asp:Label>:
<asp:TextBox ID="ConfirmEmail" runat="server" Height="18px" Width="304px" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmEmailRequired" runat="server" ControlToValidate="ConfirmEmail" CssClass="failureNotification"
ErrorMessage="Confirm E-mail is required." ToolTip="Confirm E-mail is required."
ValidationGroup="AddschoolValidationGroup">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="EmailCompare" runat="server" ControlToCompare="Email" ControlToValidate="ConfirmEmail"
CssClass="failureNotification" Display="Dynamic" ErrorMessage="E-mail and Confirm E-mail must match."
ValidationGroup="AddSchoolValidationGroup">*</asp:CompareValidator>
<asp:Label ID="Label14" runat="server" ForeColor="Red" Text="* = Required"></asp:Label>
<asp:ImageButton ID="Cancel" runat="server" OnClick="cancelClick" ImageUrl="~/Styles/images/cancel-btn.png" />
<asp:ImageButton ID="Submit" runat="server" OnClick="submitClick" ImageUrl="~/Styles/images/submit-btn.png" />
</form>
このフォームには、学校名、住所、市区町村、電子メール、コンフォーム電子メールなどのフィールドが含まれています。Asp.net 検証コントロールと 2 つの画像ボタンに加えて、1 つはキャンセル、もう 1 つは送信と名付けられています。送信をクリックすると、その検証コントロールを使用してフォームを検証し、イベント「submitclick」を発生させたい.そして、キャンセルをクリックするとイベントcancelclickを発生させたい.送信「画像ボタン」をクリックしたときにフォームを検証する方法を誰でも説明できますか.