Watermark extender via javascript

The best way to set the value of a textbox or textarea with the WatermarkExtender via Javascript:

Using the set_Text() method.

<style type="text/css">
	textarea.marked { color: #999; }
</style>

<script type="text/javascript">

	function describe() {
		$find('<%= we.ClientID %>').set_Text("Your new text here");
	};

</script>

<ajaxToolkit:TextBoxWatermarkExtender ID="we"
	TargetControlID="txt" WatermarkCssClass="marked"
	runat="server" WatermarkText="Please write here..." />

<asp:TextBox ID="txt" runat="server" TextMode="MultiLine" />

<asp:Button ID="btn" Text="Describe" runat="server"
	UseSubmitBehavior="false" OnClientClick="describe()"/>

	

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s