RangeValidator.MinimumValue Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém ou define o valor mínimo do intervalo de validação.
public:
property System::String ^ MinimumValue { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string MinimumValue { get; set; }
[System.Web.UI.Themeable(false)]
public string MinimumValue { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.MinimumValue : string with get, set
[<System.Web.UI.Themeable(false)>]
member this.MinimumValue : string with get, set
Public Property MinimumValue As String
Valor de Propriedade
O valor mínimo do intervalo de validação. O valor predefinido é Empty.
- Atributos
Exemplos
O exemplo seguinte demonstra como usar a MinimumValue propriedade para especificar o valor mínimo do intervalo de validação.
Importante
Este exemplo tem uma caixa de texto que aceita a entrada do utilizador, o que constitui uma potencial ameaça à segurança. Por defeito, as páginas Web do ASP.NET validam que a entrada do utilizador não inclui elementos de script ou HTML. Para mais informações, consulte Visão Geral dos Exploits de Scripts.
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>RangeValidator Example</title>
<script runat="server">
void ButtonClick(Object sender, EventArgs e)
{
if (Page.IsValid)
{
Label1.Text="Page is valid.";
}
else
{
Label1.Text="Page is not valid!!";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>RangeValidator Example</h3>
Enter a number from 1 to 10:
<br />
<asp:TextBox id="TextBox1"
runat="server"/>
<br />
<asp:RangeValidator id="Range1"
ControlToValidate="TextBox1"
MinimumValue="1"
MaximumValue="10"
Type="Integer"
EnableClientScript="false"
Text="The value must be from 1 to 10!"
runat="server"/>
<br /><br />
<asp:Label id="Label1"
runat="server"/>
<br /><br />
<asp:Button id="Button1"
Text="Submit"
OnClick="ButtonClick"
runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>RangeValidator Example</title>
<script runat="server">
Sub ButtonClick(sender As Object, e As EventArgs)
If Page.IsValid Then
Label1.Text="Page is valid."
Else
Label1.Text="Page is not valid!!"
End If
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>RangeValidator Example</h3>
Enter a number from 1 to 10:
<br />
<asp:TextBox id="TextBox1"
runat="server"/>
<br />
<asp:RangeValidator id="Range1"
ControlToValidate="TextBox1"
MinimumValue="1"
MaximumValue="10"
Type="Integer"
EnableClientScript="false"
Text="The value must be from 1 to 10!"
runat="server"/>
<br /><br />
<asp:Label id="Label1"
runat="server"/>
<br /><br />
<asp:Button id="Button1"
Text="Submit"
OnClick="ButtonClick"
runat="server"/>
</form>
</body>
</html>
Observações
Use a MinimumValue propriedade para especificar o valor mínimo do intervalo de validação. Se o valor especificado por esta propriedade não se converter para o tipo de dado especificado pela BaseCompareValidator.Type propriedade, é lançada uma exceção.
Note
Se especificar ValidationDataType.Date para a BaseCompareValidator.Type propriedade sem definir programaticamente a cultura para a aplicação, deve usar um formato neutro em relação à cultura, como YYYY/MM/DD, para as MaximumValue propriedades e.MinimumValue Caso contrário, a data pode não ser interpretada corretamente.
Esta propriedade não pode ser definida por temas ou temas de folhas de estilo. Para mais informações, consulte ThemeableAttribute e ASP.NET Temas e Skins.