0

我的网络表单上有一个Drop-down-list和一个。现在我需要从 java-script设置属性。我正在尝试使用on事件设置属性。但它不工作Text-boxauto-completed extenderContextKeyauto-completed extenderContextKeyjava-scriptonkeyuptext-box

.aspx 代码

<table>
    <tr>
        <td style="width:100px;">
            <asp:Label ID="Label1" CssClass="lbl" runat="server" Text="Server:"></asp:Label>
        </td>
        <td colspan="4">
            <asp:DropDownList ID="DropDownList1" CssClass="Comb" runat="server" 
                OnSelectedIndexChanged="ddlServer_SelectedIndexChanged" AutoPostBack="true">
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label2" CssClass="lbl" runat="server" Text="Originating:"></asp:Label>
        </td>
        <td colspan="4">
            <asp:TextBox runat="server" ID="TextBox1" CssClass="tb10" autocomplete="off" onkeyup="SetContextKey()"/>
            <ajaxToolkit:AutoCompleteExtender TargetControlID="TextBox1" UseContextKey="true"
                runat="server" BehaviorID="AutoCompleteEx" ID="AutoCompleteExtender1" 
                ServicePath="AutoComplete.asmx" ServiceMethod="GetResellerList"
                MinimumPrefixLength="1" CompletionInterval="1000" EnableCaching="true" FirstRowSelected="true"
                CompletionSetCount="20" CompletionListCssClass="cssList" DelimiterCharacters=";, :"
                ShowOnlyCurrentWordInCompletionListItem="true" OnClientHiding="OnClientCompleted"
                OnClientPopulated="OnClientCompleted" OnClientPopulating="OnClientPopulating">
            </ajaxToolkit:AutoCompleteExtender>
        </td>
    </tr>
</table>

.cs 代码(服务代码)

[WebMethod]
public string[] GetResellerList(string prefixText, int count, string contextKey)
{
    DataSet ds = new DataSet();
    ds = clsTransaction.Select("SELECT nm AS Name FROM tblReseller WHERE nm LIKE '" + prefixText + "%' AND wsid = '" + contextKey + "'",
        DataSendBSSWEB.ServerDbEnum.MainSqlServer,
        false);

    //Then return List of string(txtItems) as result
    List<string> txtItems = new List<string>();
    String dbValues;

    foreach (DataRow row in ds.Tables[0].Rows)
    {
        dbValues = row["Name"].ToString();
        txtItems.Add(dbValues);
    }

    return txtItems.ToArray();
}

javascript代码

<script type="text/javascript">
    function SetContextKey() {
        $find('<%=autoComplete2.ClientID%>').set_contextKey($get("<%=ddlServer.ClientID %>").value);
    }
</script>

谁能告诉我如何使用java-script.

4

1 回答 1

0

扩展器的目标控件 ID 应该是 TextBox 的 ID,而不是下拉列表的 ID。

于 2013-09-05T18:06:01.140 回答