TextBox.TextChangedとは? わかりやすく解説

TextBox.TextChanged イベント

ユーザーTextBox コントロールテキスト変更したときに発生します

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

Dim instance As TextBox
Dim handler As EventHandler

AddHandler instance.TextChanged, handler
/** @event */
public void add_TextChanged (EventHandler value)

/** @event */
public void remove_TextChanged (EventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

TextChanged イベント使用して、SelectionList 内の項目を変更する方法次の例に示します

<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage"
 %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls"
 
    Assembly="System.Web.Mobile"
 %>

<script runat="server">
    Protected Sub Page_Load(ByVal
 byvalsender As Object, _
        ByVal e As EventArgs)

        If Not IsPostBack Then
            ' Add items to the list
            SelectionList1.Items.Add(New _
                MobileListItem("Verify transactions",
 "Done"))
            SelectionList1.Items.Add(New _
                MobileListItem("Check balance sheet",
 "Scheduled"))
            SelectionList1.Items.Add(New _
                MobileListItem("Call customer", "Done"))
            SelectionList1.Items.Add(New _
                MobileListItem("Send checks", "Pending"))
            SelectionList1.Items.Add(New _
                MobileListItem("Send report", "Pending"))
            SelectionList1.Items.Add(New _
                MobileListItem("Attend meeting", "Scheduled"))

            ' Show all items in list
            SelectionList1.Rows = SelectionList1.Items.Count
        End If
    End Sub
    
    Private Sub TextChanged(ByVal
 sender As Object, _
        ByVal e As EventArgs)

        ' Called during PostBack, if changed
        Dim task As String
 = TextBox1.Text
        Dim status As String
 = TextBox2.Text
        
        If (task.Length > 0 AndAlso status.Length
 > 0) Then
            Dim li As New
 MobileListItem(task, status)

            ' Remove the item if it exists
            If (SelectionList1.Items.Contains(li)) Then
                SelectionList1.Items.Remove(li)
            Else
                ' Add the item if it does not exist
                SelectionList1.Items.Add(li)
            End If

            ' Clear the text boxes
            TextBox1.Text = String.Empty
            TextBox2.Text = String.Empty
        End If

        ' Display all items.
        SelectionList1.Rows = SelectionList1.Items.Count
    End Sub
</script>

<html xmlns="http:'www.w3.org/1999/xhtml" >
<body>
    <mobile:Form id="Form1" runat="server">
        <mobile:Label Id="Label1" runat="server">
            Create a new Task with Status</mobile:Label>
   
        <mobile:SelectionList runat="server" 
            SelectType="ListBox"
            id="SelectionList1" />
        <mobile:Label Id="Label2" runat="server"
 
            Text="Enter the Task name" />
        <mobile:TextBox runat="server" id="TextBox1"
 
            OnTextChanged="TextChanged" />
        <mobile:Label Id="Label3" runat="server"
 
            Text="Enter the Task status" />
        <mobile:TextBox runat="server" id="TextBox2"
 />
        <mobile:Command ID="Command1" runat="server"
 
            Text="Submit" />
    </mobile:Form>
</body>
</html>
<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Add items to the list
            SelectionList1.Items.Add(new 
                MobileListItem("Verify transactions","Done"));
            SelectionList1.Items.Add(new 
                MobileListItem("Check balance sheet","Scheduled"));
            SelectionList1.Items.Add(new
                MobileListItem("Call customer", "Done"));
            SelectionList1.Items.Add(new
                MobileListItem("Send checks", "Pending"));
            SelectionList1.Items.Add(new
                MobileListItem("Send report", "Pending"));
            SelectionList1.Items.Add(new
                MobileListItem("Attend meeting", "Scheduled"));

            // Show all items in list
            SelectionList1.Rows = SelectionList1.Items.Count;
        }
    }
    void TextChanged(object sender, EventArgs e)
    {
        // Called during PostBack, if changed
        string task = TextBox1.Text;
        string status = TextBox2.Text;
        
        if (task.Length > 0 && status.Length > 0)
        {

            MobileListItem li = new MobileListItem(task, status);
            
            // Remove the item if it exists
            if (SelectionList1.Items.Contains(li))
                SelectionList1.Items.Remove(li);
            else
                // Add the item if it does not exist
                SelectionList1.Items.Add(li);

            // Clear the text boxes
            TextBox1.Text = String.Empty;
            TextBox2.Text = String.Empty;
        }

        // Display all items.
        SelectionList1.Rows = SelectionList1.Items.Count;
    }
</script>

<html  >
<body>
    <mobile:Form id="Form1" runat="server">
        <mobile:Label Id="Label1" runat="server">
            Create a new Task with Status</mobile:Label>
   
        <mobile:SelectionList runat="server" BreakAfter="true"
 
            SelectType="ListBox"
            id="SelectionList1" />
        <mobile:Label Id="Label2" runat="server" 
            Text="Enter the Task name" />
        <mobile:TextBox runat="server" id="TextBox1" 
            OnTextChanged="TextChanged" />
        <mobile:Label Id="Label3" runat="server" 
            Text="Enter the Task status" />
        <mobile:TextBox runat="server" id="TextBox2" />
        <mobile:Command ID="Command1" runat="server" 
            Text="Submit" />
    </mobile:Form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TextBox.TextChanged イベント

テキスト ボックス内容サーバーへのポスト間で変更され場合発生します

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

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

TextBox.TextChangedのお隣キーワード
検索ランキング

   

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



TextBox.TextChangedのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS