Compartir a través de


OnClientChanged Property

  Microsoft Speech Technologies Homepage

Gets or sets the name of a client-side function that is called when the value of the SemanticItem control changes. Read/write.

Usage

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

Remarks

If AutoPostBack is set to True, the OnClientChanged function is executed before posting back to the server. If the author wants to persist any page state across postback, the OnClientChanged function is a good place to access the ClientViewState object of RunSpeech.

The value of the OnClientChanged 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, when the Text of the SemanticItem is changed.

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

function FunctionName ( object SemanticItem )
{
     // Client-side code referenced by SemanticItem.OnClientChanged
}

Parameters

  • SemanticItem
    The client-side SemanticItem object.

Return Value

None.

Example

The following example is based on the Commands and Context-sensitive Help sample.

<script>
  // Navigate to the SelectInfo page
  function DoGoToInfoPage() {
    SpeechCommon.Navigate("SelectInfo.aspx");
    return(false);
  }
</script>

<form id="Form1" method="post" runat="server">
  ...
  <asp:textbox id="tbWelcome" runat="server" readonly="True">
    Welcome!
  </asp:textbox>
  <asp:textbox id="tbWantInfo" runat="server"></asp:textbox>

  <speech:qa id="SayMainMenuQA" runat="server" playonce="True">
    <Prompt PromptSelectFunction="SayMainMenu_PromptFunction" 
      BargeIn="False" ID="SayMainMenu"></Prompt>
  </speech:qa>
  
  <speech:semanticmap id="TheSemanticMap" runat="server">
    <speech:semanticitem id="siYes" runat="server" targetelement="tbWantInfo" 
      targetattribute="value" onclientchanged="DoGoToInfoPage">
    </speech:semanticitem>
    <speech:semanticitem id="siNo" runat="server" targetelement="tbWantInfo"
      targetattribute="value">
    </speech:semanticitem>
  </speech:semanticmap>
  
  <speech:command id="CmdHelp" runat="server" scope="WantInfoQA" 
    type="Help" XPathTrigger="/SML/Command/Help">
    <grammar id="GlobalCmdHelp" runat="server" 
      src="Grammars/GlobalCommands.grxml" />
  </speech:command>
  
  <speech:command id="CmdMainMenu" runat="server" Scope="WantInfoQA" 
    Type="MainMenu" XPathTrigger="/SML/Command/MainMenu" 
    onclientcommand="HandleMainMenu">
    <grammar id="GlobalCmdMainMenu" runat="server" 
      Src="Grammars/GlobalCommands.grxml" />
  </speech:command>
  
  <speech:qa id="AlreadyInMainMenuQA" runat="server" 
    clientactivationfunction="IsAlreadyInMainMenu">
    <Prompt ID="SayAlreadyInMainMenu" BargeIn="False"
      PromptSelectFunction="SayAlreadyInMainMenu_PromptFunction" >
    </Prompt>
  </speech:qa>
  
  <speech:qa id="WantInfoQA" runat="server">
    <Prompt PromptSelectFunction="AskWantInfo_PromptFunction" ID="WantInfo">
      <Params>
        <speech:Param Name="bargeintype">grammar</speech:Param>
      </Params>
    </Prompt>
    <Answers>
      <speech:Answer SemanticItem="siYes" ID="SayYes" 
        XPathTrigger="/SML/Reply/Yes"></speech:Answer>
      <speech:Answer SemanticItem="siNo"  ID="SayNo" 
        XPathTrigger="/SML/Reply/No"></speech:Answer>
    </Answers>
    <Reco InitialTimeout="3000" BabbleTimeout="10000" EndSilence="1000" 
      MaxTimeout="30000" ID="recYesNo">
      <Grammars>
        <speech:Grammar Src="Grammars/YesNoGrammar.grxml" ID="YesNo">
        </speech:Grammar>
      </Grammars>
    </Reco>
  </speech:qa>
  ...
</form>

See Also

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