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

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

Button.CausesValidation プロパティ

Button コントロールクリックされたときに検証実行するかどうかを示す値を取得または設定します

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

<ThemeableAttribute(False)> _
Public Overridable Property
 CausesValidation As Boolean
Dim instance As Button
Dim value As Boolean

value = instance.CausesValidation

instance.CausesValidation = value
[ThemeableAttribute(false)] 
public virtual bool CausesValidation { get;
 set; }
[ThemeableAttribute(false)] 
public:
virtual property bool CausesValidation {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_CausesValidation ()

/** @property */
public void set_CausesValidation (boolean value)
public function get CausesValidation
 () : boolean

public function set CausesValidation
 (value : boolean)

プロパティ
Button コントロールクリックされたときに検証実行する場合trueそれ以外場合false既定値true です。

解説解説

既定では、Button コントロールクリックされたときにページ検証実行しますページ検証は、ページ上にある検証コントロール関連付けられたすべての入力コントロールが、その検証コントロールによって指定されている検証規則準拠しているかどうか判断します

CausesValidation プロパティ使用して Button コントロールクリックされたときに、クライアントサーバー両方検証実行するかどうか指定または確認できます検証実行しないようにするには、CausesValidation プロパティfalse設定します

通常、このプロパティリセット ボタンまたは消去ボタンクリックされたときに検証実行されないように、これらのボタンに対してfalse設定されます。

CausesValidation プロパティの値が true設定されている場合は、ValidationGroup プロパティ使用してButton コントロールによって発生する検証対象となる検証グループの名前を指定することもできます

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

TopicLocation
方法 : ASP.NET サーバー コントロール必要なエントリを検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールカスタム検証メッセージ表示するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールデータベースの値を検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールデータ型検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールパターンに対して検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールの値の範囲検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロール固有の値を検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロール埋め込みメッセージレイアウト指定するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロール有効性プログラムテストするASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロール検証エラー メッセージ書式設定するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロール検証無効にするASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールカスタム関数検証するASP .NET Web アプリケーション作成
方法 : ASP.NET サーバー コントロールプログラム検証するASP .NET Web アプリケーション作成
使用例使用例

CausesValidation プロパティ使用してページ検証実行されないようにする方法次のコード例示しますValidate メソッドが各検証コントロール別々にアクティブにする点に注目してください

<%@ Page Language="VB" AutoEventWireup="True"
 %>

<html> 

<head>

   <script runat="server">

      Sub SubmitButton_Click(sender As Object,
 e As EventArgs)
         
         ' Determine which button was clicked.
         Select Case (CType(sender, Button)).ID

            Case "CityQueryButton"

               ' Validate only the controls used for the city query.
               CityReqValidator.Validate()

               ' Take the appropriate action if the controls pass validation.
 
               If CityReqValidator.IsValid Then
           
                  Message.Text = "You have chosen to run a query
 for the following city: " & _ 
                     CityTextBox.Text
               
               End If

            Case "StateQueryButton"

               ' Validate only the controls used for the state query.
               StateReqValidator.Validate()

               ' Take the appropriate action if the controls pass validation.
               If StateReqValidator.IsValid Then
               
                  Message.Text = "You have chosen to run a query
 for the following state: " & _ 
                     StateTextBox.Text
               
               End If

            Case Else

               ' If the button clicked isn't recognized, erase the message
 on the page.
               Message.Text = ""

         End Select
        
      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3> Button CausesValidation Example </h3>

      <table border="1" cellpadding="10">
         <tr>
            <td>
               <b>Enter city to query.</b> <br>
               <asp:TextBox ID="CityTextBox" 
                    runat="server"/>
               <asp:RequiredFieldValidator ID="CityReqValidator"
                    ControlToValidate="CityTextBox"
                    ErrorMessage="<br>Please enter a city."
                    Display="Dynamic"
                    EnableClientScript="False"
                    runat="server"/>
            </td>
            <td valign="bottom">
               <asp:Button ID="CityQueryButton"
                    Text="Submit"
                    CausesValidation="False"
                    OnClick="SubmitButton_Click"
                    runat="server"/>
            </td>
         </tr>

         <tr>
            <td>
               <b>Enter state to query.</b> <br>
               <asp:TextBox ID="StateTextBox" 
 
                    runat="server"/>
               <asp:RequiredFieldValidator ID="StateReqValidator"
                    ControlToValidate="StateTextBox"
                    ErrorMessage="<br>Please enter a state."
                    Display="Dynamic"
                    EnableClientScript="False"
                    runat="server"/>
            </td>
            <td valign="bottom">
               <asp:Button ID="StateQueryButton"
                    Text="Submit"
                    CausesValidation="False"
                    OnClick="SubmitButton_Click"
                    runat="server"/>
            </td>
         </tr>

      </table>

      <br><br>

      <asp:Label ID="Message"
           runat="Server"/>

   </form>

</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>

<html> 

<head>

   <script runat="server">

      void SubmitButton_Click(Object sender, EventArgs e)
      {
         
         // Determine which button was clicked.
         switch(((Button)sender).ID)
         {

            case "CityQueryButton":

               // Validate only the controls used for the city query.
               CityReqValidator.Validate();

               // Take the appropriate action if the controls pass validation.
 
               if (CityReqValidator.IsValid)
               {
                  Message.Text = "You have chosen to run a query for
 the following city: " + 
                     CityTextBox.Text;
               }

               break;

            case "StateQueryButton":

               // Validate only the controls used for the state query.
               StateReqValidator.Validate();

               // Take the appropriate action if the controls pass validation.
               if (StateReqValidator.IsValid)
               {
                  Message.Text = "You have chosen to run a query for
 the following state: " + 
                     StateTextBox.Text;
               }

               break;

            default:

               // If the button clicked isn't recognized, erase the
 message on the page.
               Message.Text = "";

               break;

         }
        
      }

   </script>

</head>

<body>

   <form runat="server">

      <h3> Button CausesValidation Example </h3>

      <table border="1" cellpadding="10">
         <tr>
            <td>
               <b>Enter city to query.</b> <br>
               <asp:TextBox ID="CityTextBox" 
                    runat="server"/>
               <asp:RequiredFieldValidator ID="CityReqValidator"
                    ControlToValidate="CityTextBox"
                    ErrorMessage="<br>Please enter a city."
                    Display="Dynamic"
                    EnableClientScript="False"
                    runat="server"/>
            </td>
            <td valign="bottom">
               <asp:Button ID="CityQueryButton"
                    Text="Submit"
                    CausesValidation="False"
                    OnClick="SubmitButton_Click"
                    runat="server"/>
            </td>
         </tr>

         <tr>
            <td>
               <b>Enter state to query.</b> <br>
               <asp:TextBox ID="StateTextBox"  
                    runat="server"/>
               <asp:RequiredFieldValidator ID="StateReqValidator"
                    ControlToValidate="StateTextBox"
                    ErrorMessage="<br>Please enter a state."
                    Display="Dynamic"
                    EnableClientScript="False"
                    runat="server"/>
            </td>
            <td valign="bottom">
               <asp:Button ID="StateQueryButton"
                    Text="Submit"
                    CausesValidation="False"
                    OnClick="SubmitButton_Click"
                    runat="server"/>
            </td>
         </tr>

      </table>

      <br><br>

      <asp:Label ID="Message"
           runat="Server"/>

   </form>

</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

「Button.CausesValidation プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS