Problem If we are using watermark extender in a textbox, and also are trying to set the value of TextBox using JavaScript or jQuery, the text takes the format of watermarkCssClass style of that watermark extender .
e.g:
$('#textboxId').val("My Text");
For instance, if we set the watermark style as italic and color as gray , the text is always shown in gray italic and also behaves like a watermark text. Solution Call get_Text and set_Text methods of TextBoxWatermarkExtender to support client-side script access to the text in a watermarked text box.
Implementation
Lets take a text box with id “txtCity”
And watermarkExtender whose id is :
“watermarkExTxtCity” , target id is : “txtCity” , behaviour id is : “behTxtCity” , watermark text= “Select City”
Now inside the script tag :
- - //Find the watermark extender using behaviour id refers to city text box $find("behTxtCity" ).set_Text("My Text" ); //Similarly we can use get_Text() to take the value . - - -
Conclusion
AjaxControlToolkit controls exposes many methods to be used through client side script but unfortunately many of these are not documented (even in MS Ajax site ). We may find these methods as useful as sever side exposed methods.