我需要通过验证创建我的 UserControl。我创建了用户控件:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyValidationControl.ascx.cs" Inherits="Labs.MyValidationControl" %>
<asp:Label runat="server" ID="Name">Name</asp:Label> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Field ''Name'' is required." ControlToValidate="TextBox3" ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
<br/>
<asp:Label runat="server" ID="Password">Password</asp:Label><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RangeValidator runat="server" MinimumValue="1" MaximumValue="10" Type="Integer" id="rngText" controltovalidate="TextBox2" ValidationGroup="LoginUserValidationGroup" errormessage="The value must be from 1 to 10!" />
<br />
然后我在表单上使用 UserControl:
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:MyValidationControl runat="server"/>
</asp:Content>
当我启动我的应用程序时,我在此页面上什么也看不到。