0

我正在使用 ASP.NET AJAX 控件工具包中的 HTMLEditor 控件。工作正常。我想挂钩一个 keyup (onkeyup) 事件,这样我就可以做一些事情,比如显示编辑器中字符数的(近似)运行计数。

我推断编辑器最终是 iframe 元素内的 textarea 元素。我可以使用如下语法将事件附加到文本区域:

$addHandler($get("Editor1_ctl02_ctl01"), "keyup", displayCharCount);

这条线运行没有错误。但是,永远不会调用引用的方法 (displayCharCount)。我不知道这是否是 iframe 中的 textarea 的功能,或者控件是否已经吃掉了事件或什么。

FWIW,这在使用普通 textarea 元素的简单页面中按预期工作。

有任何想法吗?

4

1 回答 1

0

The textarea is there, but it is hidden. So your event handler may be registered, but "keyup" will never fire on a hidden control. You may want to try another event like onchange or ontextchange (or whatever its called).

The editor window you see is actually an html document in the iframe itself. The html document is in "edit mode" so it kind of resembles a textarea. The hidden textarea is simply used as a clever place to hold the html markup, so when the form is submitted, the html markup is sent to the server.

It is a tricky way to get it all to work...but it works!

于 2009-08-06T19:21:22.867 回答