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

Dim instance As LinkButton Dim value As Boolean value = instance.CausesValidation instance.CausesValidation = value
[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)
LinkButton コントロールがクリックされたときに検証を実行する場合は true。それ以外の場合は false。既定値は true です。

既定では、LinkButton コントロールがクリックされたときにページ検証を実行します。ページ検証は、ページ上にある検証コントロールに関連付けられたすべての入力コントロールが、その検証コントロールによって指定されている検証規則に準拠しているかどうかを判断します。
CausesValidation プロパティを使用して LinkButton コントロールがクリックされたときに、クライアントとサーバーの両方で検証を実行するかどうかを指定 (または確認) できます。検証を実行しないようにするには、CausesValidation プロパティを false に設定します。
通常、このプロパティは、リセット ボタンまたは消去ボタンがクリックされたときに検証が実行されないように、これらのボタンに対しては false に設定されます。
CausesValidation プロパティの値が true に設定されている場合は、ValidationGroup プロパティを使用して、LinkButton コントロールによって発生する検証の対象となる検証グループの名前を指定することもできます。
このプロパティを、テーマまたはスタイル シート テーマを使用して設定することはできません。詳細については、ThemeableAttribute、ASP.NET のテーマとスキンの概要 の各トピックを参照してください。

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, LinkButton)).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> LinkButton 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:LinkButton 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:LinkButton 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(((LinkButton)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> LinkButton 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:LinkButton 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:LinkButton 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>

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に収録されているすべての辞書からLinkButton.CausesValidation プロパティを検索する場合は、下記のリンクをクリックしてください。

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