Tutorial :Watermark text in asp.net?



Question:

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>  


Solution:1

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>  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »