可以让TextBox控件拥有水印文字。
属性:
TargetControlID :要使用具有水印效果的TextBox控件ID。
WatermarkCssClass :指定水印文字的CSS样式表。
WatermarkText :显示在TextBox控件的水印文字内容。
代码实例:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel ID="panIntTemp" runat="server"
GroupingText="新增资料">
<table>
<tr>
<td>
姓名:
</td>
<td>
<asp:TextBox ID="txtIntName" runat="server" ></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntName" runat="server"
TargetControlID="txtIntName"
WatermarkText="请在此处输入姓名">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
<td>
性别:
</td>
<td>
<asp:TextBox ID="txtIntGender" runat="server" ></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntGender" runat="server"
TargetControlID="txtIntGender"
WatermarkText="请在此处输入性别">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
<tr>
<td>
出生日期:
</td>
<td>
<asp:TextBox ID="txtIntBirthday" runat="server" ></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntBirthday" runat="server"
TargetControlID="txtIntBirthday"
WatermarkText="请在此处输入出生日期">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
<td>
家庭住址:</td>
<td>
<asp:TextBox ID="txtIntAddress" runat="server"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntAddress" runat="server"
TargetControlID="txtIntAddress"
WatermarkText="请在此处输入家庭住址">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
</tr>
</table>
</asp:Panel>
</form>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel ID="panIntTemp" runat="server"
GroupingText="新增资料">
<table>
<tr>
<td>
姓名:
</td>
<td>
<asp:TextBox ID="txtIntName" runat="server" ></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntName" runat="server"
TargetControlID="txtIntName"
WatermarkText="请在此处输入姓名">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
<td>
性别:
</td>
<td>
<asp:TextBox ID="txtIntGender" runat="server" ></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntGender" runat="server"
TargetControlID="txtIntGender"
WatermarkText="请在此处输入性别">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
<tr>
<td>
出生日期:
</td>
<td>
<asp:TextBox ID="txtIntBirthday" runat="server" ></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntBirthday" runat="server"
TargetControlID="txtIntBirthday"
WatermarkText="请在此处输入出生日期">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
<td>
家庭住址:</td>
<td>
<asp:TextBox ID="txtIntAddress" runat="server"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="tbweTxtIntAddress" runat="server"
TargetControlID="txtIntAddress"
WatermarkText="请在此处输入家庭住址">
</ajaxToolkit:TextBoxWatermarkExtender>
</td>
</tr>
</table>
</asp:Panel>
</form>
运行结果: