hi
I used below code to display remainig character into label:
<script type="text/javascript">
$(function () {
var i = 0;
$('[id*=Txtmatn]').keydown(function (e) {
var ctrlKey = 67, vKey = 86;
if (e.keyCode != ctrlKey && e.keyCode != vKey) {
$('[id*=LbltedaCh]').html(toPersianNumber($(this).val().length));
if ($(this).val().length % 70 == 0) {
i = $(this).val().length / 70;
i = toPersianNumber(i);
$('.MessageCount').html(i);
}
else {
i = $(this).val().length / 70;
i = toPersianNumber(parseInt(i));
$('.MessageCount').html(i);
}
}
});
$('[id*=Txtmatn]').keyup(function (e) {
var ctrlKey = 67, vKey = 86;
if (e.keyCode != ctrlKey && e.keyCode != vKey) {
$('[id*=LbltedaCh]').html(toPersianNumber($(this).val().length));
if ($(this).val().length % 70 == 0) {
i = $(this).val().length / 70;
i = toPersianNumber(i);
$('.MessageCount').html(i);
}
else {
i = $(this).val().length / 70;
i = toPersianNumber(parseInt(i));
$('.MessageCount').html(i);
}
}
});
$("[id*=Txtmatn]").bind('paste', function (e) {
debugger;
setTimeout(function () {
$('[id*=LbltedaCh]').html(toPersianNumber($("[id*=Txtmatn]").val().length));
var msgCount = $("[id*=Txtmatn]").val().length / 70;
msgCount = toPersianNumber(Math.floor(msgCount));
$('.MessageCount').html(msgCount);
}, 100);
});
});
function toPersianNumber(input) {
var inputstring = input;
var persian = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"]
for (var j = 0; j < persian.length; j++) {
inputstring = inputstring.toString().replace(new RegExp(j, "g"), persian[j]);
}
return inputstring;
}
</script>
it worked correctly and show number of characters into label...
I define linkbutton in page that code is:
protected void LBaddNumber_Click(object sender, EventArgs e)
{
ViewUsersInfo();
string numbers = string.Empty;
foreach (GridViewRow row in GridView1.Rows)
{
numbers += (row.FindControl("LblNumber") as Label).Text.Trim() + Environment.NewLine;
}
TxtPhone.Text = numbers.Trim();
CountMessage();
}
it will add number from gridview into other textbox...
now problem is that when I type text into textbox(TxtSms) it will display number of characters into label like:
Number of character: 158
Message count:2
Now when I click on linkbutton to add number suddenly it delete number of characters and display like:
Number of character:
Message count:
it happen when I click every linkbutton or button in page(attention that in TxtSMS are text that I typed before clicking button) it just delete number of characters...
can you help me?
Best regards
neda