Freigeben über


OnClientError Property

  Microsoft Speech Technologies Homepage

Gets or sets the name of a client-side function that is called when the platform detects a client error. Read/write.

Usage

ASP.NET markup: <speech:Prompt OnClientError="..." />
Get value: String = DialogPrompt.OnClientError;
Set value: DialogPrompt.OnClientError = String;
Data type: String
Required: No

Remarks

The purpose of the 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 the custom client-side script function, without parameters or parentheses. The client-side dialog manager calls this function, using the following syntax, when a client error event is detected.

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 DialogPrompt.OnClientError
}

Parameters

  • status
    The error code returned in the event object.

Return Value

True if the dialog manager should continue on the same page. False if it should navigate to the default error page.

Example

<form id="Form1" method="post" runat="server">
  <script>
  function FifthError ( status ) 
  {
    // Go to error page on the fifth DialogPrompt error
    if(typeof(SpeechCommon.GetViewState("PromptErrs")) == "undefined") {
      SpeechCommon.SetViewState("PromptErrs", "1");
    } else {
      SpeechCommon.SetViewState("PromptErrs", parseInt(SpeechCommon.GetViewState("PromptErrs"), 10) + 1);
    }
    if(parseInt(SpeechCommon.GetViewState("PromptErrs"), 10) > 4) {
        return false;
    } else {
        return true;
    }
  }
  </script>
  ...
  <speech:qa ID="qaOrig" runat="server">
    <Prompt ID="prmptOrig" OnClientError="FifthError"
      InlinePrompt="What is your originating city?" >
    </Prompt>
    <Reco ID="recoOrig">
      <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

DialogPrompt Class | DialogPrompt Constructor | DialogPrompt Members | DialogPrompt Properties | DialogPrompt Methods | DialogPrompt Events | DialogPrompt Remarks