Reputation: 6148
I have this password field
input class="txtfld" type="password" id="TextBoxLoginPassword" runat="server"
value="password"
onfocus="javascript:if(this.value == 'password') this.value='';"
onblur="javascript:if(this.value == '') this.value='password';"
onload="javascript:if(this.value == '') this.value='password';"
validationgroup="Login" />
Problem is that this appears as empty. Even I have set a default value. To solve this problem I have added an onload event and I get following error
Upvotes: 1
Views: 1262
Reputation: 39329
The problem is in the combination of the text in the OnLoad and the runat=server
.
Because of that runat attribute, asp.net thinks the OnLoad specifies a server-side function. And then ''
and 'password'
seem (at least to C#) to specify character literals, of which the first has too few actual characters ("Empty Character Literal") and the second too many.
So try to remove the "runat=server" (and read the password directly from the QueryString)
Upvotes: 2
Reputation: 13230
Here is a really sweet bit of JQuery / CSS that you could use here and elsewhere in your site to solve your problem:
http://attardi.org/labels/#demo
Upvotes: 1
Reputation: 19228
@Hans Kesting answer is correct, but if you don't want to use extender, you can use the following code.
<input class="txtfld" type="text" id="TextBoxLoginPassword"
value="enter password"
onfocus="javascript:if(this.type != 'password') this.value='';this.type='password'"
/>
Upvotes: 1
Reputation: 39329
It seems to me that you want to provide a "watermark", not the real password. Have you looked at the Watermark extender of the Ajax control toolkit?
Upvotes: 2