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

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

HtmlButton.CausesValidation プロパティ

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

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

Public Overridable Property
 CausesValidation As Boolean
Dim instance As HtmlButton
Dim value As Boolean

value = instance.CausesValidation

instance.CausesValidation = value
public virtual bool CausesValidation { get;
 set; }
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)

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

解説解説
使用例使用例

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, HtmlButton)).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.InnerHtml = "You have chosen to run
 a query for the following city: " & _ 
                     CityTextBox.Value
               
               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.InnerHtml = "You have chosen to run
 a query for the following state: " & _ 
                     StateTextBox.Value
               
               End If

            Case Else

               ' If the button clicked is not recognized, erase the
 message on the page.
               Message.InnerHtml = ""

         End Select
        
      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3> HtmlButton CausesValidation Example </h3>

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

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

      </table>

      <br><br>

      <span 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(((HtmlButton)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.InnerHtml = "You have chosen to run a query for
 the following city: " + 
                     CityTextBox.Value;
               }

               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.InnerHtml = "You have chosen to run a query for
 the following state: " + 
                     StateTextBox.Value;
               }

               break;

            default:

               // If the button clicked is not recognized, erase the
 message on the page.
               Message.InnerHtml = "";

               break;

         }
        
      }

   </script>

</head>

<body>

   <form runat="server">

      <h3> HtmlButton CausesValidation Example </h3>

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

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

      </table>

      <br><br>

      <span ID="Message"
            runat="Server"/>


   </form>

</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HtmlButton クラス
HtmlButton メンバ
System.Web.UI.HtmlControls 名前空間
Page.Validate
ServerClick
その他の技術情報
HTML サーバー コントロール


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

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS