After typing some text in ckeditor i am able to see the word count on button click but i need to view the word count while typing only.How can i do this.
Below is my code which gives the word count on button click
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn1_Click(object sender, EventArgs e)
{
string whole_text = CKEditor1.Text;
string trimmed_text = whole_text.Trim();
// new line split here
string[] lines = trimmed_text.Split(Environment.NewLine.ToCharArray());
// don't need this here now...
//string[] split_text = trimmed_text.Split(' ');
int space_count = 0;
string new_text = "";
foreach (string line in lines)
{
// Modify the inner foreach to do the split on ' ' here
// instead of split_text
foreach (string av in line.Split(' '))
{
if (av == "")
{
space_count++;
}
else
{
new_text = new_text + av + ",";
}
}
}
new_text = new_text.TrimEnd(',');
// use lines here instead of split_text
lines = new_text.Split(',');
//MessageBox.Show(lines.Length.ToString());
lbl1.Text = lines.Length.ToString();
}
kavitha vemulaPosted Feb 3, 2017, 4:28 AM
Suvendu Shekhar GiriPosted Feb 3, 2017, 4:21 AM