English 中文(简体)
我如何能够找到有效的人员在伙伴关系中工作。 NET?
原标题:How can I get validators to work in ASP.NET?

我试图在我的伙伴关系中进行验证。 NET Webforms application。 如今,唯一行之有效的是出生日期(DOB)领域。 这是一个习俗领域。

ASPX Code

<table>

      <tr> <td align="center" colspan="2"> 
      <asp:Label ID="RegisterTitleID" runat="server">Register here for your New Account </asp:Label></td>
      </tr>

      <tr> 
      <td align="right"> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="EmailTextBox">E-mail:</asp:Label> </td>
      <td> <asp:TextBox ID="EmailTextBox" runat="server" Height="25px" Width="200px" 
              CausesValidation="True"></asp:TextBox></td>
           <asp:RequiredFieldValidator ID="EmailRequired" runat="server" 
            ControlToValidate="EmailTextBox" ErrorMessage="E-mail is required." 
            ToolTip="E-mail is required." ValidationGroup="RegistrationWizard" 
              Display="Dynamic">*</asp:RequiredFieldValidator> </tr>

      <tr> 
      <td align="right"> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="PasswordTextBox">Password:</asp:Label> </td>
      <td> <asp:TextBox ID="PasswordTextBox" runat="server" TextMode="Password" 
              Height="25px" Width="200px" CausesValidation="True"></asp:TextBox></td> 
           <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
            ControlToValidate="PasswordTextBox" ErrorMessage="Password is required." 
            ToolTip="Password is required." ValidationGroup="RegistrationWizard" 
              Display="Dynamic">*</asp:RequiredFieldValidator> </tr>

      <tr>
      <td align="right"> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPasswordTextBox">Confirm Password:</asp:Label> </td>
      <td> <asp:TextBox ID="ConfirmPasswordTextBox" runat="server" TextMode="Password" Height="25px" Width="200px"></asp:TextBox></td>
           <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 
            ControlToValidate="ConfirmPasswordTextBox" ErrorMessage="Confirm Password is required." 
            ToolTip="Confirm Password is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>
      
      <tr> 
      <td align="center" colspan="2"> 
      <asp:CompareValidator ID="PasswordCompare" runat="server" 
            ControlToCompare="PasswordTextBox" ControlToValidate="ConfirmPasswordTextBox" 
            Display="Dynamic" 
            ErrorMessage="The Password and Confirmation Password must match." 
            ValidationGroup="RegistrationWizard"> </asp:CompareValidator> </td> </tr>

      <tr> 
      <td align="right"> <asp:Label ID="TitleLabel" runat="server" AssociatedControlID="TitleTextBox">Title:</asp:Label> </td>
      <td> <asp:TextBox ID="TitleTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td>
           <asp:RequiredFieldValidator ID="TitleRequired" runat="server" 
            ControlToValidate="TitleTextBox" ErrorMessage="Title is required." 
            ToolTip="Title is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>

      <tr> 
      <td align="right"> <asp:Label ID="FirstNameLabel" runat="server" AssociatedControlID="FirstNameTextBox">First Name:</asp:Label> </td>
      <td> <asp:TextBox ID="FirstNameTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td>
           <asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" 
            ControlToValidate="FirstNameTextBox" ErrorMessage="First Name is required." 
            ToolTip="First Name is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>

      <tr> 
      <td align="right"> <asp:Label ID="SurnameLabel" runat="server" AssociatedControlID="SurnameTextBox">Surname:</asp:Label> </td>
      <td> <asp:TextBox ID="SurnameTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td>
           <asp:RequiredFieldValidator ID="SurnameRequired" runat="server" 
            ControlToValidate="SurnameTextBox" ErrorMessage="Surname is required." 
            ToolTip="Surname is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> </tr>

      <tr> 
      <td align="right"> <asp:Label ID="DOBLabel" runat="server" AssociatedControlID="DOBTextBox">Date of Birth:</asp:Label> </td>
      <td> <asp:TextBox ID="DOBTextBox" runat="server" Height="25px" Width="200px">dd/mm/yyyy</asp:TextBox>
          </td>
           <asp:RequiredFieldValidator ID="DOBRequired" runat="server" 
            ControlToValidate="DOBTextBox" ErrorMessage="Date of birth is required." 
            ToolTip="Date of birth is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> 
           <asp:CustomValidator runat="server"
            ID="DateRangeCustomValidator" 
            ControlToValidate="DOBTextBox"
            onservervalidate="valDateRange_ServerValidate" 
            ErrorMessage="Enter a valid date. " />
            </tr>

      <tr> 
      <td align="right"> <asp:Label ID="GenderLabel" runat="server" AssociatedControlID="GenderDropDownList">Gender:</asp:Label> </td>
      <td> <asp:DropDownList ID="GenderDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
                <asp:ListItem Value="-1">Select</asp:ListItem>
                <asp:ListItem>Male</asp:ListItem>
                <asp:ListItem>Female</asp:ListItem>
                </asp:DropDownList> </td>

           <asp:RequiredFieldValidator ID="GenderRequired" runat="server" 
            ControlToValidate="GenderDropDownList" ErrorMessage="Gender is required." 
            ToolTip="Gender is required." ValidationGroup="RegistrationWizard">*</asp:RequiredFieldValidator> 
            </tr>

      <tr> 
      <td align="right"> <asp:Label ID="PhoneNumberLabel" runat="server" AssociatedControlID="PhoneNumberTextBox">PhoneNumber:</asp:Label> </td>
      <td> <asp:TextBox ID="PhoneNumberTextBox" runat="server" Height="25px" Width="200px"></asp:TextBox></td></tr>

      <tr> 
      <td align="right"> <asp:Label ID="FavouriteTeamLabel" runat="server" AssociatedControlID="FavouriteTeamDropDownList">Favourite Team:</asp:Label> </td>
      <td> 
          <asp:DropDownList ID="FavouriteTeamDropDownList" runat="server" DataSourceID="Team" 
              DataTextField="Team" DataValueField="Team" Height="27px" Width="205px">
          </asp:DropDownList>
          <asp:SqlDataSource ID="Team" runat="server" 
              ConnectionString="<%$ ConnectionStrings:RocoSportsDBConnectionString %>" 
              SelectCommand="SELECT [Team] FROM [Team]"></asp:SqlDataSource>
          </td>
      </tr>

      <tr> 
      <td align="right"> <asp:Label ID="MaritialStatusLabel" runat="server" AssociatedControlID="MaritialStatusDropDownList">Maritial Status:</asp:Label> </td>
      <td> <asp:DropDownList ID="MaritialStatusDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
                <asp:ListItem Value="-1">Select</asp:ListItem>
                <asp:ListItem>Single</asp:ListItem>
                <asp:ListItem>Married</asp:ListItem>
                <asp:ListItem>Separated</asp:ListItem>
                <asp:ListItem>Unmarried Relationship</asp:ListItem>
                <asp:ListItem>Domestic Partnership</asp:ListItem>
                </asp:DropDownList> </td>
            </tr>

      <tr> 
      <td align="right"> <asp:Label ID="EducationLabel" runat="server" AssociatedControlID="EducationDropDownList">Education:</asp:Label> </td>
      <td> <asp:DropDownList ID="EducationDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
                <asp:ListItem Value="-1">Select</asp:ListItem>
                <asp:ListItem>None</asp:ListItem>
                <asp:ListItem>Primary School</asp:ListItem>
                <asp:ListItem>Secondary School</asp:ListItem>
                <asp:ListItem>College</asp:ListItem>
                <asp:ListItem>Undergrad</asp:ListItem>
                <asp:ListItem>Postgrad</asp:ListItem>
                </asp:DropDownList> </td>
            </tr>

      <tr> 
      <td align="right"> <asp:Label ID="ProfessionLabel" runat="server" AssociatedControlID="ProfessionDropDownList">Profession:</asp:Label> </td>
      <td> <asp:DropDownList ID="ProfessionDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
                <asp:ListItem Value="-1">Select</asp:ListItem>
                <asp:ListItem>None</asp:ListItem>
                <asp:ListItem>Management</asp:ListItem>
                <asp:ListItem>Professional</asp:ListItem>
                <asp:ListItem>Armed Forces</asp:ListItem>
                <asp:ListItem>Sales</asp:ListItem>
                <asp:ListItem>Adminstrative</asp:ListItem>
                <asp:ListItem>Farming</asp:ListItem>
                <asp:ListItem>Construction</asp:ListItem>
                </asp:DropDownList> </td>
            </tr>

      <tr> 
      <td align="right"> <asp:Label ID="SalaryLabel" runat="server" AssociatedControlID="SalaryDropDownList">Salary:</asp:Label> </td>
      <td> <asp:DropDownList ID="SalaryDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
                <asp:ListItem Value="-1">Select</asp:ListItem>
                <asp:ListItem>None</asp:ListItem>
                <asp:ListItem>5000</asp:ListItem>
                <asp:ListItem>10000</asp:ListItem>
                <asp:ListItem>20000</asp:ListItem>
                <asp:ListItem>30000</asp:ListItem>
                <asp:ListItem>50000</asp:ListItem>
                <asp:ListItem>100000</asp:ListItem>
                </asp:DropDownList> </td>
            </tr>

      <tr> 
      <td align="right"> <asp:Label ID="EmploymentStatusLabel" runat="server" AssociatedControlID="EmploymentStatusDropDownList">EmploymentStatus:</asp:Label> </td>
      <td> <asp:DropDownList ID="EmploymentStatusDropDownList" runat="server" AppendDataBoundItems="true" Height="27px" Width="205px">
                <asp:ListItem Value="-1">Select</asp:ListItem>
                <asp:ListItem>Unemployed</asp:ListItem>
                <asp:ListItem>Employed</asp:ListItem>
                <asp:ListItem>Self-employed</asp:ListItem>
                <asp:ListItem>Volunteer</asp:ListItem>
                </asp:DropDownList> </td>
            </tr>
    <tr> 
      <td align="right"> <asp:Label ID="InterestsLabel" runat="server" AssociatedControlID="InterestsCheckBox">Interests:</asp:Label> </td>
      <td>
          <asp:CheckBoxList ID="InterestsCheckBox" runat="server" 
              onselectedindexchanged="InterestsCheckBox_SelectedIndexChanged">
              <asp:ListItem>Reading</asp:ListItem>
              <asp:ListItem>Football</asp:ListItem>
              <asp:ListItem>Swimming</asp:ListItem>
              <asp:ListItem>Basketball</asp:ListItem>
              <asp:ListItem>Cooking</asp:ListItem>
              <asp:ListItem>Music</asp:ListItem>
              <asp:ListItem>Philosophy</asp:ListItem>
              <asp:ListItem>Programming</asp:ListItem>
          </asp:CheckBoxList>
        </td>
    </tr>
   

      <tr> <td align="center" colspan="2" style="color:Red;"> <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>  </td> </tr>
      <tr> <td align="center" colspan="2"> <asp:Button ID="RegisterButton" runat="server" Text="Register" onclick="registerbutton_Click"/> </td> </tr>
      </table>

造成该守则不奏效的问题是什么,但并未出现任何错误? 此外,我还要对有效者表示更好的立场,给他们增加颜色?

最佳回答

除德国海关署海关验证员外,你正在使用一个鉴定小组,供所有验证人使用。

添加到您的习俗验证人上,还有《布顿登记册》。

<asp:CustomValidator runat="server"
                ID="DateRangeCustomValidator" 
                ControlToValidate="DOBTextBox"
                onservervalidate="valDateRange_ServerValidate" 
                ErrorMessage="Enter a valid date. " 
        ValidationGroup="RegistrationWizard"/>


<asp:Button ID="RegisterButton" runat="server" Text="Register"
 ValidationGroup="RegistrationWizard" onclick="registerbutton_Click"/>
问题回答

您在座右铭上打上了<条码>。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签