views:

890

answers:

1

I'm using the HTMLEditor control from the ASP.NET AJAX Control Toolkit. Works fine. I'd like to hook a keyup (onkeyup) event so that I can do things like display an (approximate) running count of the number of characters in the editor.

I've deduced that the editor is ultimately a textarea element inside an iframe element. I am able to attach events to the textarea using syntax like this:

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

This line runs without error. However, the referenced method (displayCharCount) is never invoked. I don't know whether this is a function of the textarea being in an iframe, or whether the control already eats the event or what.

FWIW, this works as expected in a simple page that uses a normal textarea element.

Any ideas?

A: 

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!

related questions