当我的页面第一次加载时,我看到文本框上的水印,但如果页面上有任何回发,水印被清除,有没有办法在文本框上保留水印?
<head runat="server">
<title></title>
<script src="scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="scripts/jquery.watermark.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#txtEmail").watermark("Email Address");
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmail" ErrorMessage="Email Invalid"></asp:RequiredFieldValidator>
</div>
</form>
</body>
答案 0 :(得分:2)
//for jquery ready
$(function () {
$("#<%= txtEmail.ClientID %>").watermark("Email Address");
});
//for partial postbacks
function pageLoad()
{
$("#<%= txtEmail.ClientID %>").watermark("Email Address");
}
答案 1 :(得分:1)