Asp.net realtime display text box word realization code
- 2020-06-01 09:32:25
- OfStack
<script language="javascript" type="text/javascript">
function countNum()
{
var count=document.getElementById("txtText").value.length;
document.getElementById("lblCount").value=count;
}
</script>
<asp:TextBox ID="txtText" name="txtText" runat="server" Columns="80" Rows="8" TextMode="MultiLine"
Width="650px" Height="150px" onkeydown="countNum();"
onmousemove="countNum();" onmouseout="countNum();" onkeyup="countNum();"></asp:TextBox>
(have input <input id="lblCount" type="button" style="border-style: none; background: none;" value="0" /> Words)
Mouse events, keyboard events
The event
describe
onClick
A mouse click event, usually a mouse click within the scope of an object's control
onDblClick
Double click event
onMouseDown
The button on the mouse was pressed
onMouseUp
The mouse is pressed down and released when the event is activated
onMouseOver
An event that is triggered when the mouse moves over the range of an object
onMouseMove
An event that is triggered when the mouse moves
onMouseOut
An event that is triggered when the mouse is out of range of an object
onKeyPress
An event that is triggered when a key on the keyboard is pressed and released.
[note: there must be a focused object in the page]
onKeyDown
An event that is triggered when a key is pressed on the keyboard [note: there must be a focused object in the page]
onKeyUp
An event that is triggered when a key on the keyboard is pressed to release [note: there must be a focused object in the page]