views:

102

answers:

2

I have a textbox in ASP.NET web form, and I need to catch the paste event from right-click context menu. But I can't see where I can catch the associated event.

The onchange event is no use, as this is only triggered when the input field loses focus. Neither does OnKeyDown event since it is not a mouse event.

Any solution?

A: 

It is a common problem to which exists no good solution.

There is no cross-browser way to capture mouse paste event.

People are getting away with running a timer to detect any change soon after it's happened and then to react to it.

Developer Art
A: 

There is the paste event in some but not all browsers. IE has had it since version 4 or 5, I think, as well as beforepaste. Firefox I think got the paste event from version 3.0, and recent versions of WebKit have it (Chrome and Safari 4 have it at least), don't know about Opera. You'd have to research the specifics such as precisely which browsers support it and which element raise the event, but I would say it's still not widely enough supported to use on the general web.

Tim Down