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

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

IValidator.ErrorMessage プロパティ

クラスによって実装された場合は、検証対象条件失敗であったときに生成されるエラー メッセージ テキスト取得または設定します

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

解説解説
使用例使用例
<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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IValidator インターフェイス
IValidator メンバ
System.Web.UI 名前空間
BaseValidator


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

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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS