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

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

ImageButton.CausesValidation プロパティ

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

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

<ThemeableAttribute(False)> _
Public Overridable Property
 CausesValidation As Boolean
Dim instance As ImageButton
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)

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

解説解説
使用例使用例

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

メモメモ

次のコード サンプルはシングルファイル コード モデル使用しており、分離コード ファイル直接コピーされ場合正常に動作しない可能性あります。このコード サンプルは、拡張子.aspx の空のテキスト ファイルコピーする必要がありますWeb フォームコード モデル詳細については、「ASP.NET Web ページコード モデル」を参照してください

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

<html> 

<head>

   <script runat="server">

      Sub SubmitButton_Click(sender As Object,
 e As ImageClickEventArgs)
         
         ' Determine which button was clicked.
         Select Case (CType(sender, ImageButton)).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> ImageButton 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:ImageButton ID="CityQueryButton"
                    ImageUrl="SubmitImage.jpg"
                    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:ImageButton ID="StateQueryButton"
                    ImageUrl="SubmitImage.jpg"
                    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, ImageClickEventArgs
 e)
      {
         
         // Determine which button was clicked.
         switch(((ImageButton)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> ImageButton 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:ImageButton ID="CityQueryButton"
                    ImageUrl="SubmitImage.jpg"
                    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:ImageButton ID="StateQueryButton"
                    ImageUrl="SubmitImage.jpg"
                    CausesValidation="False"
                    OnClick="SubmitButton_Click"
                    runat="server"/>
            </td>
         </tr>

      </table>

      <br><br>

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

   </form>

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


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

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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2024 GRAS Group, Inc.RSS