Compartir por


RangeValidator.MaximumValue Propiedad

Definición

Obtiene o establece el valor máximo del intervalo de validación.

public:
 property System::String ^ MaximumValue { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string MaximumValue { get; set; }
[System.Web.UI.Themeable(false)]
public string MaximumValue { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.MaximumValue : string with get, set
[<System.Web.UI.Themeable(false)>]
member this.MaximumValue : string with get, set
Public Property MaximumValue As String

Valor de propiedad

Valor máximo del intervalo de validación. El valor predeterminado es Empty.

Atributos

Ejemplos

En el ejemplo siguiente se muestra cómo usar la MaximumValue propiedad para especificar el valor máximo del intervalo de validación.

Importante

Este ejemplo tiene un cuadro de texto que acepta la entrada del usuario, que es una amenaza de seguridad potencial. De forma predeterminada, ASP.NET páginas web validan que la entrada del usuario no incluye elementos HTML ni de script. Para obtener más información, consulte Información general sobre vulnerabilidades de seguridad de script.


<%@ 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>

Comentarios

Utilice la MaximumValue propiedad para especificar el valor máximo del intervalo de validación. Si el valor especificado por esta propiedad no puede convertir al tipo de datos especificado por la BaseCompareValidator.Type propiedad , se produce una excepción.

Nota:

Si especifica ValidationDataType.Date para la BaseCompareValidator.Type propiedad sin establecer mediante programación la referencia cultural de la aplicación, debe usar un formato independiente de la referencia cultural, como AAAA/MM/DD, para las MaximumValue propiedades y MinimumValue . De lo contrario, es posible que la fecha no se interprete correctamente.

Esta propiedad no se puede establecer mediante temas ni temas de hojas de estilos. Para obtener más información, vea ThemeableAttribute y ASP.NET Temas y máscaras.

Se aplica a

Consulte también