1
ASP.NET驗證在ASP中似乎不起作用:FormView。有人能讓我知道我在做什麼錯嗎?謝謝。ASP.NET驗證不能在ASP FormView中工作
這是代碼。
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="ValidationSummary1" />
<asp:FormView ID="fv_LeaveRequest" runat="server" DataKeyNames="REQ_ACTION_ID">
<InsertItemTemplate>
<label>Leave Type</label>
<asp:DropDownList ID="ddl_LeaveType" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="This field is required" ValidationGroup="ValidationSummary1" Text="Required" ControlToValidate="ddl_LeaveType"></asp:RequiredFieldValidator>
<asp:Button ID="LeaveReqBtn" runat="server" Text="Submit Leave Request" CommandName="CustomInsert"
CssClass="button-position" ValidationGroup="ValidationSummary1" CausesValidation="true" />
</InsertItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="Edit" runat="server" Text="Edit/Change Request" CommandName="Edit" CssClass="button-position btn-padding" ValidationGroup="ValidationSummary1" />
<label>
Leave Type</label>
<asp:DropDownList ID="ddl_LeaveType" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="This field is required"
ValidationGroup="ValidationSummary1" Text="Required" ControlToValidate="ddl_LeaveType"></asp:RequiredFieldValidator>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="Cancel" Text="Cancel" CommandName="Cancel" runat="server" CssClass="button-position btn-padding"
ValidationGroup="ValidationSummary1" />
<label>
Leave Type</label>
<asp:DropDownList ID="ddl_LeaveType" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="This field is required"
ValidationGroup="ValidationSummary1" Text="Required" ControlToValidate="ddl_LeaveType"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:FormView>