Un required validator pentru DropDownList cu RangeValidator

Validatorul RangeValidator va aparea in UI ca un RequiredValidator. Utilizatorul nu va putea trece mai departe daca nu alege o optiune de la 1 la 5. :)

<asp:DropDownList ID="ddlTitle" runat="server">
<asp:ListItem Value="0">Select Title</asp:ListItem>
<asp:ListItem Value="1">Mr</asp:ListItem>
<asp:ListItem Value="2">Mrs</asp:ListItem>
<asp:ListItem Value="3">Miss</asp:ListItem>
<asp:ListItem Value="4">Ms</asp:ListItem>
<asp:ListItem Value="5">Dr</asp:ListItem>
</asp:DropDownList>

<asp:RangeValidator ID="rangeValidator"
Text="*"
ErrorMessage="The title is required."
ControlToValidate="ddlTitle"
Type="Integer"
MinimumValue="1"
MaximumValue="5"
runat="server"
></asp:RangeValidator>

Comments

Popular posts from this blog

IIS 7.5, HTTPS Bindings and ERR_CONNECTION_RESET

Verify ILogger calls with Moq.ILogger

Table Per Hierarchy Inheritance with Column Discriminator and Associations used in Derived Entity Types