HtmlButton.CausesValidation プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As HtmlButton Dim value As Boolean value = instance.CausesValidation instance.CausesValidation = 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 です。

既定では、HtmlButton コントロールがクリックされたときにページ検証を実行します。ページ検証は、ページ上にある検証コントロールに関連付けられたすべての入力コントロールが、その検証コントロールによって指定されている検証規則に準拠しているかどうかを判断します。
CausesValidation プロパティを使用して、HtmlButton コントロールがクリックされたときに、クライアントとサーバーの両方で検証を実行するかどうかを指定または決定できます。検証を実行しないようにするには、CausesValidation プロパティを false に設定します。
このプロパティは、通常、ServerClick イベントのイベント ハンドラで使用し、キャンセル ボタンまたは リセット ボタンがクリックされたときにページ検証が実行されないようにします。

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>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlButton.CausesValidation プロパティを検索する場合は、下記のリンクをクリックしてください。

- HtmlButton.CausesValidation プロパティのページへのリンク