OnClientError Property
Gets or sets the name of a client-side function that is called when the platform detects recognition errors. Read/write.
Usage
ASP.NET markup: | <speech:Reco OnClientError="..." /> |
Get value: | String = Reco.OnClientError; |
Set value: | Reco.OnClientError = String; |
Data type: | String |
Required: | No |
Remarks
The purpose of this script is to examine the error code and to determine whether the RunSpeech dialog manager should continue execution on the current page or should navigate to the default error page. Different types of errors are distinguished by status codes. See the onerror and onnoreco events of the SALT listen element for a list of these codes.
The value of the OnClientError property is the name of this custom client-side script function, without parameters or parentheses. The client-side dialog manager calls this function, using the following syntax, after detecting recognition errors.
The script block that contains this function should be placed before the control that calls the function. For more information, see "Placement of Script Blocks" in Authoring Notes.
Syntax
bool FunctionName ( int status )
{
// Client-side code referenced by Reco.OnClientError
}
Parameters
- status
The error code returned in the event object.
Return Value
True if the dialog manager should continue on the same page, and False if it should navigate to the default error page.
Example
The following example demonstrates a script routine that maintains a count of the error events that it has been assigned to handle. Because the routine does not evaluate the status parameter, it is the author's responsibility to assign the routine to error events only.
<form id="Form1" method="post" runat="server">
...
<script>
//
// Continue execution after the first 3 Reco errors, then quit.
//
function RecErr ( status )
{
var AllowedErrors = 3;
if(typeof(SpeechCommon.GetViewState("RecErrs")) == "undefined") {
SpeechCommon.SetViewState("RecErrs", "0");
}
SpeechCommon.SetViewState("RecErrs", parseInt(SpeechCommon.GetViewState("RecErrs"), 10) + 1);
if(parseInt(SpeechCommon.GetViewState("RecErrs"), 10) > AllowedErrors) {
return false;
}
return true;
}
</script>
...
<speech:qa id="qaOrig" runat="server">
<Prompt id="prompt1" InlinePrompt="What is your originating city?"></Prompt>
<Reco id="recoOrig" InitialTimeout="3000" BabbleTimeout="10000" EndSilence="1000" Reject="0.5"
OnClientError="RecErr" OnClientNoReco="RecErr" OnClientSilence="RecErr" >
<Grammars>
<speech:grammar src="grammars/cities.xml" runat="server"></speech:grammar>
</Grammars>
</Reco>
<Answers>
<speech:answer id="ansOrig" XPathTrigger="/sml/origcity" SemItem="siOrig" runat="server">
</speech:answer>
</Answers>
</speech:qa>
...
</form>
See Also
Reco Class | Reco Constructor | Reco Members | Reco Properties | Reco Methods | Reco Events | Reco Remarks