Showing posts with label textboxwatermarkextender. Show all posts
Showing posts with label textboxwatermarkextender. Show all posts

Wednesday, March 21, 2012

Localize TextBoxWatermarkExtender

Hi All,

How are we meant to localize the TextBoxWatermarkExtender.WatermarkText? I have a control in a detailview and so have to access it with FindControl in the cs which means that the javascript is written when the control is found so the default is already set. I do not need dynamic control over the text but the ability to localize the control before rendering would be useful.

But on the site note, how would I change the text of a control that is already rendered? I can of course change the control but it's the javascript that is produced as a result of rendering that I am having trouble over coming.

Thanks

Michael

Give this a try:

From:http://www.asp.net/AJAX/Control-Toolkit/Live/Walkthrough/OtherNeatStuff.aspx:

Using data binding to specify Extender properties

If you want to initialize Extender instances dynamically from data (instead of with server-side code), this is now supported. The example below demonstrates setting the "WatermarkText" property of a TextBoxWatermark from the "WatermarkTextField" value of a data source. A working example of Extender data binding within a Repeater can be found in the DataBinding.aspx automated test (in the ToolkitTests folder).

 <ajaxToolkit:TextBoxWatermarkExtender ID="TBWE" runat="server" TargetControlID="TextBox1"WatermarkText='<%# Eval("WatermarkTextField") %>' />
-Damien

Hi,

Thanks for the quick reply.

The information you provided was useful however the data I am trying to access is the global resources. I would normally use <%=Resources.resources.strings.WatermarkTextField %> however when I try to use this the string in the string on page is the exact string I wish to use. So how do I access the localization strings?

Michael


Can you use something like: "<%$ Resources:resources:strings, WaterMarkTextField %>" (not exactly sure of the syntax), see http://msdn.microsoft.com/msdnmag/issues/06/08/BasicInstincts/#S3 for more info.

-Damien


Hi Damien,

You were almost spot on with it. The Syntax was "<%$ Resources:resources.strings, WaterMarkTextField %>". The only difference was the second colon was a dot.

Many thanks for your help.

Michael