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

Amit ChoudharyRank #145 · 15.8K reputationPosted Apr 19, 2010, 11:19 PM EDT
you can limit your text boxes to the 150 characters using javascript..
Please mark as answer if it helps.
Kirtan PatelRank #292 · 8.6K reputationPosted Apr 19, 2010, 11:57 PM EDT
head runat="server"> title>title> script language="javascript" type="text/javascript"> function Count() { var v1 = document.getElementById('TextBox1'); var v2 = document.getElementById('lblCount'); v2.innerHTML = v1.value.length; } script> head> body> form id="form1" runat="server"> div> asp:TextBox ID="TextBox1" runat="server" OnKeyPress="Count()">asp:TextBox> asp:Label ID="lblCount" runat="server" Text="">asp:Label> div> form> body> html>Jaish MathewsRank #225 · 11K reputationPosted Apr 20, 2010, 12:29 AM EDT
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();
}
ajay rajuRank #4,639 · 333 reputationPosted Apr 20, 2010, 1:22 AM EDT
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
VasanthRank #1,487 · 1.1K reputationPosted Apr 20, 2010, 1:31 AM EDT
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>