Step 3Load the Company Matches
After the semantic item is filled, the CompanyOrTickerQA has now been satisfied, but we are still running on the client side. We need to make a few more checks, and to submit the page, so we specify in the property pages that when this QA is satisfied, and the OnClientComplete
event is fired, we want a JScript function to run.
lastCommandOrException, count, semanticItemList)
if(lastCommandOrException == "")
In the function SubmitTickerForSearch
, we do three things:
- Reset userCanceled flag: If the user was in the context of the SelectableNavigator, and cancelled out, they would be sent back to the CompanyOrTickerQA with a slightly different prompt. This variable is what tells the CompanyOrTickerQA prompt function whether the user cancelled out of the navigator control; we reset that value here.
- Reactivate Navigator: If the user was in the context of the SelectableNavigator and selected a company, the navigator would have been deactivated. We therefore want to reactivate it in the case that the user is sent back to the first QA.
- Manually submit page: Although we could have used the semantic item's AutoPostBack feature, the page would post back every time the semantic item's state changed (i.e. "Empty," "NeedConfirmation," or "Confirmed"). Instead we manually submit the page if the lastCommandOrException parameter is blank.
Once our semantic item has been filled (and therefore its state is no longer "Empty"), we want to retrieve matching values from the database. In the LoadCompanies()
function on the server, we decide which method to call and retrieve the data.
siTicker.Text.Replace(" amp ", " & "));
throw new ApplicationException(...));
We use the semantic item's "ResponseType" attribute, which we set in the Client Normalization Function SetResponseType
, to determine if we received a match on a company or on a ticker. If we get an unrecognized value in "ResponseType," we manually throw an application exception.
|Tip: In server-side code, reference a semantic item's attributes collection with an upper-case "A" (siTicker.Attributes); in client-side script, however, remember that it's a lower-case "a" (siTicker.attributes).