Setting WatermarkText in JavaScript

To set the Watermark Text of a TextBoxWatermarkExtender in the AJAX Control Toolkit, use the following code:

var behavior = $find('<%= TextBoxWatermarkExtender1.ClientID %>');
behavior.clearText();
behavior.set_Text('Hello World!');
behavior.initialize();

It took me a while to find that I needed to call the Initialize() function before the Watermark Text would get updated.


Update September 25, 2012

It appears that different versions of the AJAX Control Toolkit have different public methods.

var behavior = document.getElementById("<%= TextBox1.ClientID%>").AjaxControlToolkitTextBoxWrapper;
behavior.set_Watermark('');

http://stackoverflow.com/questions/2701875/ajaxtoolkit-textboxwatermarkextender-how-to-change-the-text-from-javascript

ASP.Net AJAX Animations

Some of the best resources for the animation framework that comes with the ASP.Net AJAX Control Toolkit can be found at the live toolkit site at this Sample Site. I often look at the Animation Reference section of this site.

While adding animations to ASP.Net pages, it is sometimes necessary to call animations directly from Javascript code. This can be achieved relatively easily using the great instructions at this MSDN blog.

Combined with the Animation Reference on http://asp.net/ajax website, any animation can be called directly from Javascript. If you can’t use the <OnLoad> animation event handler in the AnimationExtender control, one way to play animations on the page load is to use ClientScriptManager.RegisterStartupScript to create a function with the animation code, and call that function on the next line.


Page.ClientScript.RegisterStartupScript(Me.GetType, “PlayLoadAnimation”, “function playNotificationAnimation(){ AjaxControlToolkit.Animation.ColorAnimation.play($get(“”divNotification””) , 1 , 30 , “”style”” , “”backgroundColor”” , “”#181840″” , “”#E9E8FF””); }”, True)

Page.ClientScript.RegisterStartupScript(Me.GetType, “LoadAnimationFunction”, “playNotificationAnimation();”, True)

Happy Animating!
Zachary Lyons