如何在键入时获取ck编辑器字数而不是在按钮单击时显示计数 [英] How to get the ck editor word count while typing instead of displaying the count on button click

查看:101
本文介绍了如何在键入时获取ck编辑器字数而不是在按钮单击时显示计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ckeditor中输入一些文字后,我可以看到按钮点击上的字数,但我只需要在打字时查看字数。我怎么能这样做。



下面是我的代码,它给出按钮点击的字数



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

<body>
    <form id="form1" runat="server">
   <div>
   <CKEditor:CKEditorControl ID="CKEditor1" BasePath="/ckeditor/" runat="server">
   </CKEditor:CKEditorControl>
           <asp:Button ID="btn1" runat="server" OnClick="btn1_Click" Text="Get Word Count" />
       <asp:Label ID="lbl1" runat="server"></asp:Label>
</div>
    </form>
</body>







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();
        }





我的尝试:



如何在键入时获取单词计数,而不是单击按钮上的单词计数



What I have tried:

how can i get the word count while typing instead of getting the word count on button click

推荐答案

有一个插件。你试过了吗?您可以在此处找到它: Word Count& Char Count插件| CKEditor.com [ ^ ]
There is a plugin for that. Have you tried it yet? You can find it here: Word Count & Char Count Plugin | CKEditor.com[^]

这篇关于如何在键入时获取ck编辑器字数而不是在按钮单击时显示计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆