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

Dim instance As IValidator Dim value As String value = instance.ErrorMessage instance.ErrorMessage = value
string ErrorMessage { get; set; }
生成するエラー メッセージ。

Web フォーム ページを開発している場合、検証サーバー コントロールの開始タグで宣言することによって、このプロパティにアクセスします。詳細については、「検証サーバー コントロール構文」を参照してください。

<HTML> <HEAD> <script language="VB" runat="server"> Sub Button_Click(sender As [Object], e As EventArgs) ' Generating a random number. Dim rand_number As New Random() myCompareValidate.ValueToCompare = rand_number.Next(1, 10).ToString() ' Set the ErrorMessage. myCompareValidate.ErrorMessage = "Try Again!!" myCompareValidate.Validate() ' Check for Validity of control. If myCompareValidate.IsValid And myTextBox.Text <> "" Then labelOutput.Text = "You guessed correctly!!" labelOutput.ForeColor = System.Drawing.Color.Blue Else labelOutput.Text = "You guessed poorly" labelOutput.ForeColor = System.Drawing.Color.Black End If labelOutput.Text += "<br><br>" + "The number is: " + _ myCompareValidate.ValueToCompare End Sub 'Button_Click </Script> </HEAD> <body> <form runat="server" ID="myForm"> <h3>IValidator Example demonstrating IsValid & ErrorMessage</h3> <h5>Guess!! a number between 1 and 10:</h5> <asp:TextBox id="myTextBox" runat="server" /> <asp:CompareValidator id="myCompareValidate" ControlToValidate="myTextBox" ValueToCompare="0" EnableClientScript="False" Type="Integer" Text="*" runat="server" /> <br> <asp:Button Text="Submit" OnClick="Button_Click" runat="server" /> <br> <asp:Label id="labelOutput" runat="server" /> <br> <asp:ValidationSummary id="Summary1" runat="server" /> </form> </body> </HTML>
<HTML> <HEAD> <script language="C#" runat="server"> void Button_Click(Object sender, EventArgs e) { // Generating the random number. Random rand_number = new Random(); myCompareValidate.ValueToCompare = rand_number.Next(1, 10).ToString(); // Setting the ErrorMessage. myCompareValidate.ErrorMessage="Try Again!!"; myCompareValidate.Validate(); // Check for Validity of control. if ((myCompareValidate.IsValid) && (myTextBox.Text != "")) { labelOutput.Text = "You guessed correctly!!"; labelOutput.ForeColor = System.Drawing.Color.Blue; } else { labelOutput.Text = "You guessed poorly"; labelOutput.ForeColor = System.Drawing.Color.Black; } labelOutput.Text += "<br><br>" + "The number is: " + myCompareValidate.ValueToCompare; } </script> </HEAD> <body> <form runat="server" ID="myForm"> <h3>IValidator Example demonstrating IsValid & ErrorMessage</h3> <h5>Guess!! a number between 1 and 10 :</h5> <asp:TextBox id="myTextBox" runat="server" /> <asp:CompareValidator id="myCompareValidate" ControlToValidate="myTextBox" ValueToCompare="0" EnableClientScript="False" Type="Integer" Text="*" runat="server" /> <br> <asp:Button Text="Submit" OnClick="Button_Click" runat="server" /> <br> <asp:Label id="labelOutput" runat="server" /> <br> <asp:ValidationSummary id="Summary1" runat="server" /> </form> </body> </HTML>
<HTML> <HEAD> <script language="VJ#" runat="server"> void Button_Click(Object sender, EventArgs e) { // Generating the random number. Random randNumber = new Random(); myCompareValidate.set_ValueToCompare( System.Convert.ToString(randNumber.Next(1, 10))); // Setting the ErrorMessage. myCompareValidate.set_ErrorMessage("Try Again!!"); myCompareValidate.Validate(); // Check for Validity of control. if (myCompareValidate.get_IsValid() && (!(myTextBox.get_Text().Equals("")))) { labelOutput.set_Text("You guessed correctly!!"); labelOutput.set_ForeColor(System.Drawing.Color.get_Blue()); } else { labelOutput.set_Text("You guessed poorly"); labelOutput.set_ForeColor(System.Drawing.Color.get_Black()); } labelOutput.set_Text(labelOutput.get_Text() + "<br><br>" + "The number is: " + myCompareValidate.get_ValueToCompare()); } //Button_Click </script> </HEAD> <body> <form runat="server" ID="myForm"> <h3>IValidator Example demonstrating IsValid & ErrorMessage</h3> <h5>Guess!! a number between 1 and 10 :</h5> <asp:TextBox id="myTextBox" runat="server" /> <asp:CompareValidator id="myCompareValidate" ControlToValidate="myTextBox" ValueToCompare="0" EnableClientScript="False" Type="Integer" Text="*" runat="server" /> <br> <asp:Button ID="Button1" Text="Submit" OnClick="Button_Click" runat="server" /> <br> <asp:Label id="labelOutput" runat="server" /> <br> <asp:ValidationSummary id="Summary1" 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に収録されているすべての辞書からIValidator.ErrorMessage プロパティを検索する場合は、下記のリンクをクリックしてください。

- IValidator.ErrorMessage プロパティのページへのリンク