Hi Dan,
If you want a client-side click event then use onclick in the declaration and run some javascript
:
<asp:textbox runat="server" id="txtClickabl e" onclick="alert( 'clicked!');" text="[click into me for an alert]" />
If you want a server-side click event you could derive a class from TextBox and implement IPostBackEventH andler. Use the
ClientScriptMan ager (Page.ClientScr ipt) to render a post-back reference in the onclick attribute's javascript (.NET 2.0) or by using
a method of the Page class (.NET 1.*). In each case the method is called GetPostBackEven tReference, and it will write javascript
that causes the page to be posted back and the RaisePostBackEv ent method to be invoked on your class, where you can raise your
custom Click event. Be careful here, however, because your TextBox will not be useable on the client if you always render the
onclick javascript to post back. This is because each time the user clicks in your box, it will post back to the server and they
will never be able to actually enter text. And if you call txtClickable.Fo cus() in the 2.0 framework, it might be an endless
post-back loop!
--
Dave Sexton
"Dan Aldean" <do*******@roge rs.comwrote in message news:O0******** ******@TK2MSFTN GP03.phx.gbl...
Hi,
I create a WEB application and I use a textbox, server control.
It does not have an OnClick event. Is it possible to create one?
Thanks