Wednesday, March 21, 2012

delete ajax Extender with Javascript

hi

I have a problem with AutoCompleteExtender.

the code in HTML

<tr id="trUserName">
<td>
<asp:TextBox runat="server" id="txtUserName" />
<ajax:AutoCompleteExtender id="aceUserName" runat="server" TargetControlId="txtUserName"..... />
</td>
</tr>

when I run script below, it has errors.

var node = document.getElementById('trUserName');
node.parentNode.removeChild(node);

I have tried, if <tr /> tag without any Extender Control, it can be removed.

and I have to remove control in javascript.

Can you help me ?

Hi Benelf,

I think the best way for your situation is put them inside a div container. When you want to delete it, you can hide the div. For example,

<tr id="trUserName">
<td>

<div id="automCompleteContainer">
<asp:TextBox runat="server" id="txtUserName" />
<ajax:AutoCompleteExtender id="aceUserName" runat="server" TargetControlId="txtUserName"..... />

</div>
</td>
</tr>

To hide it , you can do it like this. document.all.automCompleteContainer.style.display ="none";

If you insist on deleting them, I suggest that you should first dispose() the AutoCompleteExtender by using $find("AutoCompleteExtender's BehavoirID").dispose().

I hope this help.

Best regards,

Jonathan

No comments:

Post a Comment