且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在运行时单击文本框后,默认文本应消失

更新时间:2023-01-15 20:16:43

您正在谈论的文本框水印.就像我们在CP for Search中在右上角广告下方的顶部绿色栏中所显示的那样.

这是通过使用Javascript完成的.您有几种选择:
1.根据需要即时编写类似行为的Javasscript-您需要在文本框的onfocus/onclick/onkeydown(任何此类事件)上引发一个事件并清除其值.
2.制作具有此行为的自定义控件并使用它.
3.使用现有的第三方控件.例如: AJAX工具包TextBoxWatermark演示 [
You are talking of Textbox Watermarks. Like the one we have here in CP for Search in the Top Green bar just below the Ad at top-right corner.

It is done via using Javascript. You have few options:
1. Write your own Javasscript for the similar behavior on the fly as and when required - You would need to raise an event onfocus/onclick/onkeydown (any such event) of the textbox and clear it''s value.
2. Make a custom control that has this behaviour and use it.
3. Use existing thrid party controls. For example: AJAX toolkit TextBoxWatermark Demonstration[^]

I would prefer 2 or 3.


尝试此链接

点击 [
Try this Link

Click[^]