Wednesday, March 28, 2012

Extending the AutoCompleteExtender

Hi,

I'm trying to extend the AutoCompleteExtender so that is also can return an extra (hidden) value. For now I just do this by passing the text and the value returned by the WebMethod just as a comma separated string, i.e. "AnObject;5" (where 5 is the ID of the object). I just started on this so I'm not sure of I'm doing things the way they are supposed too. So here's a question.

I managed to extend the AutoCompleteBehavior javascript so that I can pass the result of the WebMethod to the TextBox and it just shows the text (the value is split of).

I also added an extra property ValueTextBoxId to the Properties of the AutoCompleteExtender to reference the TextBox which should store the hidden value. I have now the correct ClientId of the TextBox in the javascript. Next step is setting the value of that textbox.

I can use $(this.get_valueTextBoxId()).value to set it. But I guess it's more in the ways of Atlas to use the Sys.Ui.TextBox object. Only I cannot find any documentation how I can use that object when I have just a ClientID.

Anybody an idea?

Not sure of the solution to your other issues, but to use the Sys.UI.TextBox with a client id you need only do this.

var AtlasTextBox = new Sys.UI.TextBox($(ClientID));
AtlasTextBox.initialize(); // I can't remember if this line is required or not.

Jay

No comments:

Post a Comment