asp.net 实现水印textbox
2010-09-06 20:23
169 查看
<textarea cols="50" rows="15" name="code" class="c-sharp"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="测试焦点图.aspx.cs" Inherits="测试焦点图" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<title>loverszhaokai</title>
</head>
<body>
<form runat="server">
<mce:style type="text/css"><!--
.WaterMarkedTextBox
{
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
color: #666666;
font-size: 8pt;
text-align: left;
}
.WaterMarkedTextBoxPSW
{
background-position: center;
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
background-color: #F0F8FF;
color: white;
vertical-align: middle;
text-align: right;
background-repeat: no-repeat;
}
.NormalTextBox
{
height: 16px;
width: 168px;
}
--></mce:style><style type="text/css" mce_bogus="1"> .WaterMarkedTextBox
{
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
color: #666666;
font-size: 8pt;
text-align: left;
}
.WaterMarkedTextBoxPSW
{
background-position: center;
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
background-color: #F0F8FF;
color: white;
vertical-align: middle;
text-align: right;
background-repeat: no-repeat;
}
.NormalTextBox
{
height: 16px;
width: 168px;
}
</style>
<mce:script language="javascript" type="text/javascript"><!--
function Focus(objname, waterMarkText) {
obj = document.getElementById(objname);
if (obj.value == waterMarkText) {
obj.value = "";
obj.className = "NormalTextBox";
if (obj.value == "loverszhaokai" || obj.value == "" || obj.value == null) {
obj.style.color = "#666666";
}
}
}
function Blur(objname, waterMarkText) {
obj = document.getElementById(objname);
if (obj.value == "") {
obj.value = waterMarkText;
if (objname != "txtPwd") {
obj.className = "WaterMarkedTextBox";
}
else {
obj.className = "WaterMarkedTextBoxPSW";
}
}
else {
obj.className = "NormalTextBox";
}
if (obj.value == "loverszhaokai" || obj.value == "" || obj.value == null) {
obj.style.color = "gray";
}
else {
obj.style.color = "black";
}
}
// --></mce:script>
<td>
<asp:TextBox ID="txtUserId" runat="server" onfocus="Focus(this.id,'loverszhaokai')" onblur="Blur(this.id,'loverszhaokai')"
Width="126px" CssClass="WaterMarkedTextBox">loverszhaokai</asp:TextBox>
</td>
</tr>
<tr>
<td>
</body>
</form>
</html>
</textarea>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<title>loverszhaokai</title>
</head>
<body>
<form runat="server">
<mce:style type="text/css"><!--
.WaterMarkedTextBox
{
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
color: #666666;
font-size: 8pt;
text-align: left;
}
.WaterMarkedTextBoxPSW
{
background-position: center;
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
background-color: #F0F8FF;
color: white;
vertical-align: middle;
text-align: right;
background-repeat: no-repeat;
}
.NormalTextBox
{
height: 16px;
width: 168px;
}
--></mce:style><style type="text/css" mce_bogus="1"> .WaterMarkedTextBox
{
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
color: #666666;
font-size: 8pt;
text-align: left;
}
.WaterMarkedTextBoxPSW
{
background-position: center;
height: 16px;
width: 168px;
padding: 2px 2 2 2px;
border: 1px solid #BEBEBE;
background-color: #F0F8FF;
color: white;
vertical-align: middle;
text-align: right;
background-repeat: no-repeat;
}
.NormalTextBox
{
height: 16px;
width: 168px;
}
</style>
<mce:script language="javascript" type="text/javascript"><!--
function Focus(objname, waterMarkText) {
obj = document.getElementById(objname);
if (obj.value == waterMarkText) {
obj.value = "";
obj.className = "NormalTextBox";
if (obj.value == "loverszhaokai" || obj.value == "" || obj.value == null) {
obj.style.color = "#666666";
}
}
}
function Blur(objname, waterMarkText) {
obj = document.getElementById(objname);
if (obj.value == "") {
obj.value = waterMarkText;
if (objname != "txtPwd") {
obj.className = "WaterMarkedTextBox";
}
else {
obj.className = "WaterMarkedTextBoxPSW";
}
}
else {
obj.className = "NormalTextBox";
}
if (obj.value == "loverszhaokai" || obj.value == "" || obj.value == null) {
obj.style.color = "gray";
}
else {
obj.style.color = "black";
}
}
// --></mce:script>
<td>
<asp:TextBox ID="txtUserId" runat="server" onfocus="Focus(this.id,'loverszhaokai')" onblur="Blur(this.id,'loverszhaokai')"
Width="126px" CssClass="WaterMarkedTextBox">loverszhaokai</asp:TextBox>
</td>
</tr>
<tr>
<td>
</body>
</form>
</html>
</textarea>
相关文章推荐
- 关于asp.net中TextBox里面实现回车触发的解决方案
- Asp.Net中动态实现图片水印
- C#通用类实现 读取xml控制Asp.net控件输入信息长度(TextBox,FileUpload)
- asp.net中水印的实现代码
- asp.net中TextBox里面实现回车触发指定事件
- 用ASP.NET实现简单的文字水印
- AjaxPro.NET实现TextBox智能获取服务端数据功能(Asp.net 2.0)(示例代码下载) 转载
- ASP.NET中实现在图片上打水印
- asp .net textbox实现点击文本消失
- Asp.net 实现图片缩放 无水印(方法一)
- ASP.NET实现简单的文字水印
- Asp.net全站图片加水印:实现IHttpHandler接口
- C#通用类实现 读取xml控制Asp.net控件输入信息长度(TextBox,FileUpload)
- asp.net如何在图片上加水印文字具体实现
- Asp.Net图片数字水印的实现
- ASP.NET图片加水印的实现代码
- asp.net的多行文本框(TextBox)随内容增加而高度增加,并且不显示垂直滚动条的实现!
- asp.net通过实现IHttpHandler接口方法给图片添加水印图片(动态添加,不破坏原图片,但是耗资源)