Hi nedash,
I have created a sample which full fill your requirement you need to modify the code according to your need.
HTML
<div>
<div>
<input name="TxtSMS" type="text" id="TxtSMS" />
<br />
Character Count:- <span id="LblCount"></span>
<br />
Number Of Messages:- <span id="Lblsend" class="MessageCount"></span>
<br />
Quantity:- <span id="LblQuantity" class="MessageCount"></span>
<br />
Sum:- <span id="lblsum" class="Sun"></span>
<br />
English Sum:- <span id="lblSumEnglish" class="Sun"></span>
</div>
<div>
<asp:GridView ID="gvNumber" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField HeaderText="Number">
<ItemTemplate>
<asp:Label ID="LblNumber" Text='<%#Eval("Number")%>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="btnAdd" Text="Add" OnClick="LBaddNumber_Click" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th>
Number of count:<asp:Label ID="LblNumberCount" Text="" runat="server" />
</th>
</tr>
<tr>
<td>
<asp:TextBox ID="TxtPhone" TextMode="MultiLine" Width="150px" Height="120px" runat="server" />
</td>
</tr>
</table>
</div>
</div>
<div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var i = 0;
$('[id*=TxtSMS]').keydown(function (e) {
var ctrlKey = 67, vKey = 86;
if (e.keyCode != ctrlKey && e.keyCode != vKey) {
$('[id*=LblCount]').html(toPersianNumber($(this).val().length));
if ($(this).val().length % 70 == 0) {
i = $(this).val().length / 70;
//for Persian
$('[id*=lblsum]').html(toPersianNumber(i * ($('[Id*=LblNumberCount]').html())));
// for English
$('[id*=lblSumEnglish]').html(i * ($('[Id*=LblNumberCount]').html()));
i = toPersianNumber(i);
$('.MessageCount').html(i);
}
else {
i = $(this).val().length / 70;
i = toPersianNumber(parseInt(i));
$('.MessageCount').html(i);
}
}
});
$('[id*=TxtSMS]').keyup(function (e) {
var ctrlKey = 67, vKey = 86;
if (e.keyCode != ctrlKey && e.keyCode != vKey) {
$('[id*=LblCount]').html(toPersianNumber($(this).val().length));
if ($(this).val().length % 70 == 0) {
i = $(this).val().length / 70;
//for Persian
$('[id*=lblsum]').html(toPersianNumber(i * ($('[Id*=LblNumberCount]').html())));
// for English
$('[id*=lblSumEnglish]').html(i * ($('[Id*=LblNumberCount]').html()));
i = toPersianNumber(i);
$('.MessageCount').html(i);
}
else {
i = $(this).val().length / 70;
i = toPersianNumber(parseInt(i));
$('.MessageCount').html(i);
}
}
});
$("[id*=TxtSMS]").bind('paste', function (e) {
setTimeout(function () {
$('[id*=LblCount]').html(toPersianNumber($("[id*=TxtSMS]").val().length));
var msgCount = $("[id*=TxtSMS]").val().length / 70;
//for Persian
$('[id*=lblsum]').html(toPersianNumber(Math.floor(msgCount) * (Math.floor($('[Id*=LblNumberCount]').html()))));
//For English
$('[id*=lblSumEnglish]').html(Math.floor(msgCount) * (Math.floor($('[Id*=LblNumberCount]').html())));
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>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Number", typeof(int));
dt.Rows.Add("25635863");
dt.Rows.Add("254635863");
dt.Rows.Add("256667863");
dt.Rows.Add("256377563");
gvNumber.DataSource = dt;
gvNumber.DataBind();
}
}
protected void LBaddNumber_Click(object sender, EventArgs e)
{
GridViewRow row = (sender as LinkButton).NamingContainer as GridViewRow;
string number = (row.FindControl("LblNumber") as Label).Text.Trim();
if (!string.IsNullOrEmpty(TxtPhone.Text))
{
TxtPhone.Text = number.Trim() + Environment.NewLine + TxtPhone.Text;
}
else
{
TxtPhone.Text = number.Trim();
}
LblNumberCount.Text = (TxtPhone.Text.Split('\r').Length).ToString();
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dt As New DataTable()
dt.Columns.Add("Number", GetType(Integer))
dt.Rows.Add("25635863")
dt.Rows.Add("254635863")
dt.Rows.Add("256667863")
dt.Rows.Add("256377563")
gvNumber.DataSource = dt
gvNumber.DataBind()
End If
End Sub
Protected Sub LBaddNumber_Click(sender As Object, e As EventArgs)
Dim row As GridViewRow = TryCast(TryCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim number As String = TryCast(row.FindControl("LblNumber"), Label).Text.Trim()
If Not String.IsNullOrEmpty(TxtPhone.Text) Then
TxtPhone.Text = number.Trim() + Environment.NewLine + TxtPhone.Text
Else
TxtPhone.Text = number.Trim()
End If
LblNumberCount.Text = (TxtPhone.Text.Split(ControlChars.Cr).Length).ToString()
End Sub