BaseCompareValidator.Type プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BaseCompareValidator.Type プロパティの意味・解説 

BaseCompareValidator.Type プロパティ

比較実行される前に比較対象の値が変換されるデータ型取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

<ThemeableAttribute(False)> _
Public Property Type As
 ValidationDataType
Dim instance As BaseCompareValidator
Dim value As ValidationDataType

value = instance.Type

instance.Type = value
[ThemeableAttribute(false)] 
public ValidationDataType Type { get; set;
 }
[ThemeableAttribute(false)] 
public:
property ValidationDataType Type {
    ValidationDataType get ();
    void set (ValidationDataType value);
}
/** @property */
public ValidationDataType get_Type ()

/** @property */
public void set_Type (ValidationDataType value)
public function get Type
 () : ValidationDataType

public function set Type
 (value : ValidationDataType)

プロパティ
ValidationDataType 列挙値の 1 つ既定値String です。

例外例外
例外種類条件

ArgumentException

指定されデータ型が、ValidationDataType 値ではありません。

解説解説

Type プロパティ使用して比較使用するデータ型指定しますType プロパティは、各種比較検証コントロールによって、さまざまな使われ方をします。

メモ重要 :

現在のカレンダー形式グレゴリオ暦ない場合Type プロパティDate設定すると、検証コントロールサーバー側の検証だけを実行します検証コントロールクライアント スクリプトでは、グレゴリオ暦だけがサポートされます。

たとえば RangeValidator コントロールでは、比較実行前に比較対象すべての値 (上限下限、および入力コントロールの値) が指定されデータ型変換されます。ただし、CompareValidator コントロール使用し、その Operator プロパティValidationCompareOperator.DataTypeCheck設定した場合は、入力コントロールの値だけが指定されデータ型変換されます。

Type プロパティ使用できる値を次の表に示します

このプロパティテーマ別またはスタイル シート テーマ別設定することはできません。詳細については、ThemeableAttribute、ASP.NETテーマスキン概要 の各トピック参照してください

使用例使用例

Type プロパティ使用して比較実行前に比較対象の値の変換使用するデータ型指定する方法次のコード例示します

<%@ Page Language="VB" AutoEventWireup="True"
 %>
 
<html>
<head>
   <script runat="server">
 
      Sub Button_Click(sender As Object,
 e As EventArgs) 
 
         If Page.IsValid Then 
         
            lblOutput.Text = "Result: Valid!"
         
         Else 
         
            lblOutput.Text = "Result: Not valid!"
         
         End If

      End Sub
 
      Sub Operator_Index_Changed(sender As
 Object, e As EventArgs) 

         Compare1.Operator = CType(ListOperator.SelectedIndex, ValidationCompareOperator)
         Compare1.Validate()

      End Sub

      Sub Type_Index_Changed(sender As Object,
 e As EventArgs) 

         Compare1.Type = CType(ListType.SelectedIndex, ValidationDataType)
         Compare1.Validate()

      End Sub
 
   </script>
 
</head>
<body>
 
   <form runat=server>

      <h3>CompareValidator Example</h3>
      <p>
      Enter a value in each textbox. Select
 a comparison operator<br>
      and data type. Click "Validate"
 to compare values.
 
      <table bgcolor="#eeeeee" cellpadding=10>

         <tr valign="top">

            <td>

               <h5>String 1:</h5>
               <asp:TextBox id="TextBox1" 
                    runat="server"/>

            </td>

            <td>

               <h5>Comparison Operator:</h5>
 
               <asp:ListBox id="ListOperator" 
                    OnSelectedIndexChanged="Operator_Index_Changed"
 
                    runat="server">

                  <asp:ListItem Selected Value="Equal">Equal</asp:ListItem>
                  <asp:ListItem Value="NotEqual">NotEqual</asp:ListItem>
                  <asp:ListItem Value="GreaterThan">GreaterThan</asp:ListItem>
                  <asp:ListItem Value="GreaterThanEqual">GreaterThanEqual</asp:ListItem>
                  <asp:ListItem Value="LessThan">LessThan</asp:ListItem>
                  <asp:ListItem Value="LessThanEqual">LessThanEqual</asp:ListItem>
                  <asp:ListItem Value="DataTypeCheck">DataTypeCheck</asp:ListItem>

               </asp:ListBox>

            </td>

            <td>

               <h5>String 2:</h5>
               <asp:TextBox id="TextBox2" 
                    runat="server"/>
               <p>
               <asp:Button id="Button1"
                    Text="Validate"  
                    OnClick="Button_Click" 
                    runat="server"/>

            </td>
         </tr>

         <tr>
            <td colspan="3" align="center">

               <h5>Data Type:</h5>

               <asp:ListBox id="ListType" 
                    OnSelectedIndexChanged="Type_Index_Changed"
 
                    runat="server">

                  <asp:ListItem Selected Value="String"
 >String</asp:ListItem>
                  <asp:ListItem Value="Integer"
 >Integer</asp:ListItem>
                  <asp:ListItem Value="Double"
 >Double</asp:ListItem>
                  <asp:ListItem Value="Date" >Date</asp:ListItem>
                  <asp:ListItem Value="Currency"
 >Currency</asp:ListItem>

               </asp:ListBox>
            </td>
         </tr>
      </table>
 
      <asp:CompareValidator id="Compare1" 
           ControlToValidate="TextBox1" 
           ControlToCompare="TextBox2"
           EnableClientScript="False" 
           Type="String" 
           runat="server"/>
 
      <br>
       
      <asp:Label id="lblOutput" 
           Font-Name="verdana" 
           Font-Size="10pt" 
           runat="server"/>
 
   </form>
 
</body>
</html>

<%@ Page Language="C#" AutoEventWireup="True" %>
 
<html>
<head>
   <script runat="server">
 
      void Button_Click(Object sender, EventArgs e) 
      {
 
         if (Page.IsValid) 
         {
            lblOutput.Text = "Result: Valid!";
         }
         else 
         {
            lblOutput.Text = "Result: Not valid!";
         }

      }
 
      void Operator_Index_Changed(Object sender, EventArgs e)
 
      {

         Compare1.Operator = (ValidationCompareOperator) ListOperator.SelectedIndex;
         Compare1.Validate();

      }

      void Type_Index_Changed(Object sender, EventArgs e) 
      {

         Compare1.Type = (ValidationDataType) ListType.SelectedIndex;
         Compare1.Validate();

      }
 
   </script>
 
</head>
<body>
 
   <form runat=server>

      <h3>CompareValidator Example</h3>
      <p>
      Enter a value in each textbox. Select a comparison operator<br>
      and data type. Click "Validate" to compare values.
 
      <table bgcolor="#eeeeee" cellpadding=10>

         <tr valign="top">

            <td>

               <h5>String 1:</h5>
               <asp:TextBox id="TextBox1" 
                    runat="server"/>

            </td>

            <td>

               <h5>Comparison Operator:</h5>
 
               <asp:ListBox id="ListOperator" 
                    OnSelectedIndexChanged="Operator_Index_Changed" 
                    runat="server">

                  <asp:ListItem Selected Value="Equal">Equal</asp:ListItem>
                  <asp:ListItem Value="NotEqual">NotEqual</asp:ListItem>
                  <asp:ListItem Value="GreaterThan">GreaterThan</asp:ListItem>
                  <asp:ListItem Value="GreaterThanEqual">GreaterThanEqual</asp:ListItem>
                  <asp:ListItem Value="LessThan">LessThan</asp:ListItem>
                  <asp:ListItem Value="LessThanEqual">LessThanEqual</asp:ListItem>
                  <asp:ListItem Value="DataTypeCheck">DataTypeCheck</asp:ListItem>

               </asp:ListBox>

            </td>

            <td>

               <h5>String 2:</h5>
               <asp:TextBox id="TextBox2" 
                    runat="server"/>
               <p>
               <asp:Button id="Button1"
                    Text="Validate"  
                    OnClick="Button_Click" 
                    runat="server"/>

            </td>
         </tr>

         <tr>
            <td colspan="3" align="center">

               <h5>Data Type:</h5>

               <asp:ListBox id="ListType" 
                    OnSelectedIndexChanged="Type_Index_Changed" 
                    runat="server">

                  <asp:ListItem Selected Value="String" >String</asp:ListItem>
                  <asp:ListItem Value="Integer" >Integer</asp:ListItem>
                  <asp:ListItem Value="Double" >Double</asp:ListItem>
                  <asp:ListItem Value="Date" >Date</asp:ListItem>
                  <asp:ListItem Value="Currency" >Currency</asp:ListItem>

               </asp:ListBox>
            </td>
         </tr>
      </table>
 
      <asp:CompareValidator id="Compare1" 
           ControlToValidate="TextBox1" 
           ControlToCompare="TextBox2"
           EnableClientScript="False" 
           Type="String" 
           runat="server"/>
 
      <br>
       
      <asp:Label id="lblOutput" 
           Font-Name="verdana" 
           Font-Size="10pt" 
           runat="server"/>
 
   </form>
 
</body>
</html>

<%@ Page Language="JScript" AutoEventWireup="True" %>
 
<html>
<head>
   <script runat="server">
 
      function Button_Click(sender, e : EventArgs) 
      {
 
         if (Page.IsValid) 
         {
            lblOutput.Text = "Result: Valid!";
         }
         else 
         {
            lblOutput.Text = "Result: Not valid!";
         }

      }
 
      function Operator_Index_Changed(sender, e : EventArgs) 
      {

         Compare1.Operator = ValidationCompareOperator(ListOperator.SelectedIndex);
         Compare1.Validate();

      }

      function Type_Index_Changed(sender, e : EventArgs) 
      {

         Compare1.Type = ValidationDataType(ListType.SelectedIndex);
         Compare1.Validate();

      }
 
   </script>
 
</head>
<body>
 
   <form runat=server>

      <h3>CompareValidator Example</h3>
      <p>
      Enter a value in each textbox. Select a comparison operator<br>
      and data type. Click "Validate" to compare values.
 
      <table bgcolor="#eeeeee" cellpadding=10>

         <tr valign="top">

            <td>

               <h5>String 1:</h5>
               <asp:TextBox id="TextBox1" 
                    runat="server"/>

            </td>

            <td>

               <h5>Comparison Operator:</h5>
 
               <asp:ListBox id="ListOperator" 
                    OnSelectedIndexChanged="Operator_Index_Changed" 
                    runat="server">

                  <asp:ListItem Selected Value="Equal">Equal</asp:ListItem>
                  <asp:ListItem Value="NotEqual">NotEqual</asp:ListItem>
                  <asp:ListItem Value="GreaterThan">GreaterThan</asp:ListItem>
                  <asp:ListItem Value="GreaterThanEqual">GreaterThanEqual</asp:ListItem>
                  <asp:ListItem Value="LessThan">LessThan</asp:ListItem>
                  <asp:ListItem Value="LessThanEqual">LessThanEqual</asp:ListItem>
                  <asp:ListItem Value="DataTypeCheck">DataTypeCheck</asp:ListItem>

               </asp:ListBox>

            </td>

            <td>

               <h5>String 2:</h5>
               <asp:TextBox id="TextBox2" 
                    runat="server"/>
               <p>
               <asp:Button id="Button1"
                    Text="Validate"  
                    OnClick="Button_Click" 
                    runat="server"/>

            </td>
         </tr>

         <tr>
            <td colspan="3" align="center">

               <h5>Data Type:</h5>

               <asp:ListBox id="ListType" 
                    OnSelectedIndexChanged="Type_Index_Changed" 
                    runat="server">

                  <asp:ListItem Selected Value="String" >String</asp:ListItem>
                  <asp:ListItem Value="Integer" >Integer</asp:ListItem>
                  <asp:ListItem Value="Double" >Double</asp:ListItem>
                  <asp:ListItem Value="Date" >Date</asp:ListItem>
                  <asp:ListItem Value="Currency" >Currency</asp:ListItem>

               </asp:ListBox>
            </td>
         </tr>
      </table>
 
      <asp:CompareValidator id="Compare1" 
           ControlToValidate="TextBox1" 
           ControlToCompare="TextBox2"
           EnableClientScript="False" 
           Type="String" 
           runat="server"/>
 
      <br>
       
      <asp:Label id="lblOutput" 
           Font-Name="verdana" 
           Font-Size="10pt" 
           runat="server"/>
 
   </form>
 
</body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BaseCompareValidator クラス
BaseCompareValidator メンバ
System.Web.UI.WebControls 名前空間
ValidationDataType


このページでは「.NET Framework クラス ライブラリ リファレンス」からBaseCompareValidator.Type プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBaseCompareValidator.Type プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBaseCompareValidator.Type プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「BaseCompareValidator.Type プロパティ」の関連用語

BaseCompareValidator.Type プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BaseCompareValidator.Type プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS