我想製作一個動態字符計數器,顯示文本框中的text.length。我試圖使用textchanged,但我認爲我錯過了一塊,因爲我的標籤根本不顯示任何值。動態字符計數器 - 標籤不顯示任何東西
ASP
<tr>
<td style="vertical-align: middle">
Note to Buyer:
</td>
<td>
<asp:TextBox ID="txtNoteToBuyer" runat="server" Height="150px" MaxLength="425" TextMode="MultiLine" Width="400px"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblCharacterCount" runat="server"></asp:Label>
</td>
</tr>
VB
Protected Sub txtNoteToBuyer_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNoteToBuyer.TextChanged
lblCharacterCount.Text = Len(txtNoteToBuyer.Text)
End Sub
不要做這個服務器端。改用JavaScript。否則,您必須在輸入的每個字符後重新輸入頁面。 – Santi
好的電話。謝謝! – Cole