AJAX Control Toolkit : Controls like TextBoxWatermarkExtender do not support setting value dynamically

by brunofig 21. December 2006 02:04

 

If a value is set using the Sys.Preview.UI.TextBox.set_text, the TextBoxWatermarkBehavior will override the value if the control gains focus.

This happens because the value of the field this._watermarked inside the TextBoxWatermarkBehavior is not changed to true.

The TextBoxWatermarkBehavior only works well for user input.

The workaround for this checking first if the html element has the Behaviour, and if so, set the value using the behaviour:

	if (txtCO.get_element().TextBoxWatermarkBehavior){	txtCO.get_element().TextBoxWatermarkBehavior.set_Text("hello world!");}else{	txtCO.set_text("hello world!");}
	

If the TextBoxWatermarkBehavior where to be changed, the initialize method of the beaviour could check for the existence of the control property in the html element, and if so, attach the text property change event to his keypress event, solving the problem. A issue with this was open at codeplex. Go there and vote.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.7
Theme by Mads Kristensen

About the author

Hi!

My name is Bruno and I'am a senior consultant. When I'm not working, you can catch me playing with my daugther, taking photos and hanging out with my wife and friends. :)

You can also check my dark side or have fun with my vision of the world.

View Bruno Figueiredo's profile on LinkedIn

TwitterCounter for @brunoshine
 
Creative Commons License

 
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
 

Ads

    Page List

      Most comments

      Busby SEO Test Busby SEO Test
      2 comments
      kh Cambodia
      laptop cases laptop cases
      2 comments
      Busby SEO Test Busby SEO Test
      1 comments

      RecentComments

      Comment RSS

      Popuri.us

      My Popularity (by popuri.us)