hi! sir
i place one textbox and label. i take textboxbox properties is multiline:True and Maxlength:150
and bottom of the text i take lable. and label text is 150. (Characters Left: 150)
my aim is when i enter text in text box , in the label value is decreased. and cut,paste,delete operations are also performed.
means if i cut the text that time label value is increase and if i paste the text label value is decrease.
if label value is reach '0' if i try to enter text in textbox, text is not entered.
plrase give a code for this.(This is web application)
one doubt i set maxlength is 150 to the textbox control and take multiline is true. if i reach 150 characters and type text also it is print.
why print the text in textbox i reach the maxlength?
please give a solution.
Thanks.
Loading
VasanthPosted Apr 20, 2010, 5:31 AM
asp:textbox id="txtValue" runat="server" onkeypress="return CheckLength(this,150)" onkeyup="return CheckLength(this,150)" onkeydown="return CheckLength(this,150)" onPaste="return CheckLength(this,150)">asp:textbox>
ajay rajuPosted Apr 20, 2010, 5:22 AM
if we not using java script we not give a maxium characters limit? and i am using maxlenght property of textbox. but after characters reach max limit then also we enter values into textbox it takes the characters. why?
Thanks
Jaish MathewsPosted Apr 20, 2010, 4:29 AM
Below one for me. As I understood your need, you don't need to display the total text count, but you need to display remaining possible text count in side TextBox.
My aspx
My Codebehind
if (!IsPostBack)
{
TextBox1.Attributes.Add("onpropertychange", "handleChange(this);");
}
My Javascript
function handleChange(ctrl)
{
var length = ctrl.value.length;
var displayValue = new Number(150) - new Number(length)
$get("myLabel").innerText = displayValue.toString();
}
Kirtan PatelPosted Apr 20, 2010, 3:57 AM
Amit ChoudharyPosted Apr 20, 2010, 3:19 AM
you can limit your text boxes to the 150 characters using javascript..
See Demo
Please mark as answer if it helps.