Ajaxtoolkit TextboxWatermarkExtender: how to change text from Javascript

I think that thaAjaxControlToolkitTextBoxWrapper is used to work, but I think that updating to the latest version of Toolkit (4) broke it:

    var txtExpireYear = document.getElementById("ctl00_phPageContent_dtmPassportExpirationDate_txtYear");
  txtExpireYear.AjaxControlToolkitTextBoxWrapper.set_Value(dtmDateOfExpire.getFullYear()); 

Now I get the error:

Microsoft JScript runtime error: 'AjaxControlToolkitTextBoxWrapper' is null or not an object

Doing this:

txtExpireYear.innerText = "value1" txtExpireYear.value = "value2"

changes the text of the watermark, not the text of the text field.

+3
source share
3 answers

Try the following:

Change

txtExpireYear.AjaxControlToolkitTextBoxWrapper.set_Value(dtmDateOfExpire.getFullYear()); 

For this:

txtExpireYear.TextBoxWrapper.set_Value(dtmDateOfExpire.getFullYear())

If this does not work, replace the ScriptManager control that you use for the AjaxToolkit "ToolkitScriptManager" replacement control

+2
source

TextBoxWatermarkExtender.

javascript, ID :

<asp:TextBox ID="myTextBox" ... />
<ajaxtoolkit:TextBoxWatermarkExtender ID="myTextBoxWatermark" BehaviorID="myTextBoxBehavior" TargetControlID="myTextBox"  WatermarkText="Enter data here ..." ... />

javascript set_Text()

$find('myTextBoxBehavior').set_Text('Entered Data');

, get_Text(),

+3

If you want to change the text of the watermark itself, there is also a method set_WatermarkText().

Turning around on the example of Edwin:

$find('myTextBoxBehavior').set_WatermarkText('Entered Data'); 
0
source

Source: https://habr.com/ru/post/1742531/


All Articles