RangeValidator.MaximumValue Proprietà

Definizione

Ottiene o imposta il valore massimo dell'intervallo di convalida.

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

Valore della proprietà

Valore massimo dell'intervallo di convalida. Il valore predefinito è Empty.

Attributi

Esempio

Nell'esempio seguente viene illustrato come utilizzare la MaximumValue proprietà per specificare il valore massimo dell'intervallo di convalida.

Importante

L'esempio include una casella di testo che accetta l'input dell'utente e rappresenta quindi una potenziale minaccia alla sicurezza. Per impostazione predefinita, le pagine Web ASP.NET verificano che l'input dell'utente non includa script o elementi HTML. Per altre informazioni, vedere Cenni preliminari sugli attacchi tramite 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>

Commenti

Utilizzare la MaximumValue proprietà per specificare il valore massimo dell'intervallo di convalida. Se il valore specificato da questa proprietà non riesce a eseguire la conversione nel tipo di dati specificato dalla BaseCompareValidator.Type proprietà , viene generata un'eccezione.

Nota

Se si specifica ValidationDataType.Date per la BaseCompareValidator.Type proprietà senza impostare le impostazioni cultura per l'applicazione a livello di codice, è consigliabile usare un formato indipendente dalle impostazioni cultura, ad esempio AAAA/MM/GG, per le MaximumValue proprietà e MinimumValue . In caso contrario, la data potrebbe non essere interpretata correttamente.

Questa proprietà non può essere impostata da temi oppure temi di fogli di stile. Per altre informazioni, vedere ThemeableAttribute e ASP.NET Temi e interfacce.

Si applica a

Vedi anche