I have a form where I'm using an AutoCompleteBox to allow users to select a client from the database and create some information to attach to that client. If the client doesn't already exist, I have a quick input form on the same page that allows them to add the new client to the database. This triggers a server-side event that inserts the client info and returns the Client Name and an automatically generated Client ID that I use to create a token for AutoCompleteBox.
I'm using the OnClientEntryAdded & OnClientEntryRemoved events to control whether the Add Client form inputs are enabled or disabled. Basically, if a token exists, they cannot add a new client to the database. This works if I load a token through the AutoCompleteBox. The input fields are cleared and disabled when a token is loaded and reenabled if all tokens are removed from the AutoCompleteBox.
The issues occurs when I fire the server-side click event for the Add Client information. I insert the new record and create a token that I add to the AutoCompleteBox then the OnClientEntryAdded event automatically fires once all the server-side events are complete. The logical operator shown below in my sample script works. It correctly finds that the AutoCompleteBox now has 1 entry but then when it tries to clear and disable the textbox, it throws a null or undefined object error. The best I can determine, is that the OnClientEntryAdded is fired before the textboxes are available in the DOM but I have no idea how to workaround this. Any help is appreciated.
function NewClientInputsToggle(sender, eventArgs) {
if ($find("<%= racClientSearch.ClientID %>").get_entries().get_count() == 0) {
$find("<%= txtNewClient.ClientID %>").enable();
}
else {
$find("<%= txtNewClient.ClientID %>").clear();
$find("<%= txtNewClient.ClientID %>").disable();
}
}
I'm using the OnClientEntryAdded & OnClientEntryRemoved events to control whether the Add Client form inputs are enabled or disabled. Basically, if a token exists, they cannot add a new client to the database. This works if I load a token through the AutoCompleteBox. The input fields are cleared and disabled when a token is loaded and reenabled if all tokens are removed from the AutoCompleteBox.
The issues occurs when I fire the server-side click event for the Add Client information. I insert the new record and create a token that I add to the AutoCompleteBox then the OnClientEntryAdded event automatically fires once all the server-side events are complete. The logical operator shown below in my sample script works. It correctly finds that the AutoCompleteBox now has 1 entry but then when it tries to clear and disable the textbox, it throws a null or undefined object error. The best I can determine, is that the OnClientEntryAdded is fired before the textboxes are available in the DOM but I have no idea how to workaround this. Any help is appreciated.
function NewClientInputsToggle(sender, eventArgs) {
if ($find("<%= racClientSearch.ClientID %>").get_entries().get_count() == 0) {
$find("<%= txtNewClient.ClientID %>").enable();
}
else {
$find("<%= txtNewClient.ClientID %>").clear();
$find("<%= txtNewClient.ClientID %>").disable();
}
}