ClientActivationFunction Property

  Microsoft Speech Technologies Homepage

Gets or sets the name of a client-side function that determines if the QA control can be activated. Read/write.

Usage

ASP.NET markup: <speech:QA ClientActivationFunction="..." />
Get value: String = QA.ClientActivationFunction;
Set value: QA.ClientActivationFunction = String;
Data type: String
Required: No; Default: True

Remarks

The value of the ClientActivationFunction property is the name of a custom client-side script function, without parameters or parentheses. The client-side dialog manager calls this function, using the following syntax, passing parameters that contain information about the current state of the user's interaction with the client browser. The script function may use this information, and any other available data, to activate or deactivate the QA control as appropriate.

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 ( object source )
{
     // Client-side code referenced by QA.ClientActivationFunction
}

Parameters

  • source
    The client-side QA object being tested for activation.

Return Value

A variable of type Boolean with a value of True if the QA should be activated, or False if the QA should be deactivated.

Example

In the following example, the first QA attempts to collect the name of a color and place it in a SemanticItem called siColor. Because the PlayOnce property of this QA is true, RunSpeech does not reactivate the control, regardless of the user input.

If siColor contains a recognized color name, the second QA will be activated by its ClientActivationFunction and will play a "Thank you" prompt. If siColor is empty, the third QA will be activated by its ClientActivationFunction and will play a "Sorry" prompt.

<form id="Form1" method="post" runat="server">
  <script>
    function HasSucceed(objQA) {
      return (siColor.IsEmpty() == false);
    }
    function HasFailed(objQA) {
      return (siColor.IsEmpty());
    }
  </script>
  ...
  <asp:TextBox id="tbColor" runat="server"></asp:TextBox>
  <Speech:SemanticMap id="TheSemanticMap" runat="server">
      <speech:semanticitem id="siColor" runat="server" targetattribute="value" targetelement="tbColor"></speech:semanticitem>
  </Speech:SemanticMap>

  <speech:QA runat="server" id="ColorQA" PlayOnce="true">
    <Prompt InlinePrompt="Please name a color." ID="AskColor">
      <Params>
        <speech:Param Name="bargeintype">grammar</speech:Param>
      </Params>
    </Prompt>
    <Answers>
      <speech:Answer SemanticItem="siColor" ID="ColorA" XPathTrigger="/SML"></speech:Answer>
    </Answers>
    <Reco Reject="0.5" InitialTimeout="3000" BabbleTimeout="10000" EndSilence="1000" MaxTimeout="30000">
      <Grammars>
        <speech:Grammar Src="Grammars/ColorGrammar.grxml"></speech:Grammar>
      </Grammars>
    </Reco>
  </speech:QA>

  <speech:QA id="ThankYouQA" runat="server" ClientActivationFunction="HasSucceed" PlayOnce="True">
    <Prompt InlinePrompt="Thank you." BargeIn="False" ID="SayThankYou"></Prompt>
  </speech:QA>
  <speech:QA id="SorryQA" runat="server" ClientActivationFunction="HasFailed" PlayOnce="True">
    <Prompt InlinePrompt="Sorry." BargeIn="False" ID="SaySorry"></Prompt>
  </speech:QA>
</form>

See Also

QA Class | QA Constructor | QA Members | QA Properties | QA Methods | QA Events | QA Remarks | QA Client Object