views:

247

answers:

2

I think thaAjaxControlToolkitTextBoxWrapperThis use to work, but I think that upgrading to te latest version of teh Toolkit (4 something) broke it:

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

I now get the error:

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

Executing this:

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

results in the watermark text being changed, not the textbox's text.

A: 

Try this:

Change

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

To this:

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

If it doesn't work, swap the ScriptManager control you are using for the AjaxToolkit replacement control "ToolkitScriptManager"

Velika
A: 

The text of the textbox is handled by the behavior object of the TextBoxWatermarkExtender.

To access this object in javascript, first specify an ID for the behavior:

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

In javascript, find this object and use set_Text() method

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

Similar, there is a get_Text() method, to get the actual value of the textbox

Edwin
That looks like the declarative equivalent to what I said used to work in the previous version of the tool kit.
Velika