Surya sasidhar
Surya sasidhar

Reputation: 30313

Watermark text in asp.net?

in my web application i am using javascript for water mark text in textboxes it is working fine but for textbox if TextMode property set to Multiline then the water mark text is not displaying is there any particular reason. this is my code...

<TextBox ID="txtone" runat="server" tooltip="Enter comments"
 onblur="if(this.value=='') this.value='Enter text,150 characters only';"
 onfocus="if(this.value == 'Enter text,150 characters only') this.value='';" 
 value="Enter text,150 characters only">
</TextBox>

Upvotes: 2

Views: 1111

Answers (1)

Guffa
Guffa

Reputation: 700342

When a TextBox is in multiline mode, it's rendered as a textarea instead of an input element. The textarea element doesn't use the value attribute, so your code fails to set the initial value.

Use the Text property of the server control instead of the value argument of the client control:

<TextBox ID="txtone" runat="server" tooltip="Enter comments"
onblur="if(this.value=='') this.value='Enter text,150 characters only';"
onfocus="if(this.value == 'Enter text,150 characters only') this.value='';"
Text="Enter text,150 characters only"></TextBox>

Upvotes: 3

Related Questions