TextBox コンストラクタとは? わかりやすく解説

TextBox コンストラクタ


TextBox コンストラクタ

TextBox クラス新しインスタンス初期化します。

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

解説解説
使用例使用例

TextBox コンストラクタ使用してページTextBox コントロール動的に追加する方法次のコード例示します

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

<html> 

<head>

   <script runat="server">

      Protected Sub Page_Load(sender As
 Object, e As EventArgs)

         ' Create UserTextBox TextBox control.
         Dim UserTextBox As New
 TextBox()

         ' Configure the UserTextBox TextBox control.
         UserTextBox.ID = "UserTextBox"
         UserTextBox.Columns = 50


         ' Add UserTextBox TextBox control to the Controls collection
 
         ' of the TextBoxControlPlaceHolder PlaceHolder control.
         TextBoxControlPlaceHolder.Controls.Add(UserTextBox)

      End Sub

      Protected Sub Submit_Click(sender As
 Object, e As EventArgs)

         ' Retrieve the UserTextBox TextBox control from the TextBoxControlPlaceHolder
         ' PlaceHolder control.
         Dim TempTextBox As TextBox = CType(TextBoxControlPlaceHolder.FindControl("UserTextBox"),
 TextBox)

         ' Display the Text property.
         Message.Text = "The TextBox control above is dynamically
 generated. <br> You entered: " & _ 
                        TempTextBox.Text

      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3> TextBox Constructor Example </h3>

      Enter some text and click the Submit button. <br><br>

      <asp:PlaceHolder ID="TextBoxControlPlaceHolder"
           runat="server"/>

      <br><br>
 
      <asp:Button ID="SubmitButton"
           Text="Submit"
           OnClick="Submit_Click"
           runat="server"/>

      <br><br>

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


   </form>

</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>

<html> 

<head>

   <script runat="server">

      protected void Page_Load(Object sender,
 EventArgs e)
      {

         // Create UserTextBox TextBox control.
         TextBox UserTextBox = new TextBox();

         // Configure the UserTextBox TextBox control.
         UserTextBox.ID = "UserTextBox";
         UserTextBox.Columns = 50;


         // Add UserTextBox TextBox control to the Controls collection
 
         // of the TextBoxControlPlaceHolder PlaceHolder control.
         TextBoxControlPlaceHolder.Controls.Add(UserTextBox);

      }

      protected void Submit_Click(Object sender,
 EventArgs e)
      {

         // Retrieve the UserTextBox TextBox control from the TextBoxControlPlaceHolder
         // PlaceHolder control.
         TextBox TempTextBox = (TextBox)TextBoxControlPlaceHolder.FindControl("UserTextBox");

         // Display the Text property.
         Message.Text = "The TextBox control above is dynamically generated.
 <br> You entered: " + 
                        TempTextBox.Text;

      }

   </script>

</head>

<body>

   <form runat="server">

      <h3> TextBox Constructor Example </h3>

      Enter some text and click the Submit button. <br><br>

      <asp:PlaceHolder ID="TextBoxControlPlaceHolder"
           runat="server"/>

      <br><br>
 
      <asp:Button ID="SubmitButton"
           Text="Submit"
           OnClick="Submit_Click"
           runat="server"/>

      <br><br>

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


   </form>

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

TextBox コンストラクタ

TextBox クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説
使用例使用例

TextBox コントロール新しインスタンス作成し文字列コントロールText プロパティ代入するコード例次に示します

Public Sub CreateMyTextBoxControl()
    ' Create a new TextBox control using this constructor.
    Dim textBox1 As New
 TextBox()
    ' Assign a string of text to the new TextBox control.
    textBox1.Text = "Hello World!"

    ' Code goes here to add the control to the form's control collection.
End Sub

public void CreateMyTextBoxControl()
 {
    // Create a new TextBox control using this constructor.
    TextBox textBox1 = new TextBox();
    // Assign a string of text to the new TextBox control.
    textBox1.Text = "Hello World!";
    // Code goes here to add the control to the form's control collection.
 }
       
public:
   void CreateMyTextBoxControl()
   {
      // Create a new TextBox control using this constructor.
      TextBox^ textBox1 = gcnew TextBox;
      // Assign a string of text to the new TextBox control.
      textBox1->Text = "Hello World!";
      // Code goes here to add the control to the form's control collection.
   }
public void CreateMyTextBoxControl()
{
    // Create a new TextBox control using this constructor.
    TextBox textBox1 = new TextBox();
    // Assign a string of text to the new TextBox control.
    textBox1.set_Text("Hello World!");
    // Code goes here to add the control to the form's control collection.
} //CreateMyTextBoxControl
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「TextBox コンストラクタ」の関連用語

TextBox コンストラクタのお隣キーワード
検索ランキング

   

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



TextBox コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS