您的位置:首页 > 编程语言 > ASP

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息