Compartir a través de


Attributes Property

  Microsoft Speech Technologies Homepage

Gets or sets a collection of name-value pairs to pass user-defined semantic information between the client SemanticItem control and the server. Read-only.

Usage

ASP.NET markup: <speech:SemanticItem Attributes="..." />
Get value: StringDictionary = SemanticItem.Attributes;
Set value: Read-only
Data type: StringDictionary
Required: No

Remarks

The Attributes property can be used to store additional or temporary information about the SemanticItem.

Application authors can add attributes to the attributes property of the client-side SemanticItem object. Authors should not initialize any attribute to null; doing so will cause a run-time error.

Example

In the following example, a Application Speech Control collects a credit card type and a credit card number. It places the credit card number in its target SemanticItem and places the credit card type in the cardType attribute of the SemanticItem. The OnServerEvent routine handles both the Changed and the Confirmed events. This routine displays the credit card number, the credit card type and the semantic state of the SemanticItem whenever the card number is changed or confirmed.

<form id="Form1" method="post" runat="server">
  ...
  <script language="C#" runat="server">
    void OnServerEvent(Object sender, Microsoft.Speech.Web.UI.SemanticEventArgs e)
    {
      tbServerCCNum.Text=siCCard.Text;
      tbServerCCTyp.Text=siCCard.Attributes["cardType"];
      if (siCCard.State==SemanticState.Empty) tbState.Text="Empty";
      if (siCCard.State==SemanticState.NeedsConfirmation) tbState.Text="NeedsConfirmation";
      if (siCCard.State==SemanticState.Confirmed) tbState.Text="Confirmed";
    }
  </script>
  ...
  <speech:SemanticMap ID="SemanticMap" runat="server">
    <speech:SemanticItem 
      ID="siCCard" runat="server" 
      OnConfirmed="OnServerEvent" 
      OnChanged="OnServerEvent" 
      TargetAttribute="value" 
      TargetElement="tbClientCCNum" 
      BindOnChanged="false" 
      AutoPostBack="true"></speech:SemanticItem>
  </speech:SemanticMap>
      
  <asp:label runat="server">CC number (client)</asp:Label>
  <asp:TextBox ID="tbClientCCNum" Runat="server"></asp:TextBox><br>
  <asp:label runat="server">CC number (server)</asp:Label>
  <asp:TextBox ID="tbServerCCNum" Runat="server"></asp:TextBox><br>
  <asp:label runat="server">CC type (server)</asp:Label>
  <asp:TextBox ID="tbServerCCTyp" Runat="server"></asp:TextBox><br>
  <asp:label runat="server">Semantic State (server)</asp:Label>
  <asp:TextBox ID="tbState" Runat="server"></asp:TextBox>
      
  <speech:AnswerCall SpeechIndex="10" ID="AnswerCall1" runat="server">
  </speech:AnswerCall>
  <speech:CreditCardNumber  
    SpeechIndex="20" 
    QuestionPrompt="Please say your credit card number" 
    AllowAmex="true" 
    AllowDinersClub="true" 
    AllowDiscover="true" 
    AllowMasterCard="true"
    SemanticItem="siCCard"
    runat="server" ID="Creditcardnumber1">
  </speech:CreditCardNumber>
  ...
</form>

See Also

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