Menu

Pass multiple parameter in “Ajax Auto Extender”

Hello Friend,

Here we have to give simple example of “Ajax Auto Extender” with multiple parameter.

Country
 <asp:DropDownList ID="ddl_topCountryList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_topCountryList_SelectedIndexChanged"
 Width="210px" CssClass="dropdown" />

State name

 <asp:TextBox ID="txtSearchStateName" runat="server" CssClass="textEntryCountry" MaxLength="100"
 Width="210px"></asp:TextBox>

 <ajax:AutoCompleteExtender runat="server" ID="AutoCompleteExtender1" BehaviorID="AutoCompleteExtender1"
 TargetControlID="txtSearchStateName" ServiceMethod="GetStateName" MinimumPrefixLength="1"
 OnClientPopulating="LoadAutoComplete" CompletionInterval="10" EnableCaching="true"
 CompletionSetCount="20" CompletionListItemCssClass="autocomplete_listItem" CompletionListCssClass="autocomplete_completionListElement"
 CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" UseContextKey="true"
 DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true" ServicePath="~/Ajax.asmx">

 </ajax:AutoCompleteExtender>
// Set UseContext Key = True

Pass argument using javascript function


<script type="text/javascript">
 function LoadAutoComplete(source, eventArgs) {
 SetContextKeyValue();
 }
 function SetContextKeyValue() {
 $find('AutoCompleteExtender1').set_contextKey($get("<%=ddl_topCountryList.ClientID %>").value);
 }
 </script>

Create Service “Ajax.asmx”


[WebMethod]
 [System.Web.Script.Services.ScriptMethod]
 public string[] GetStateName(string prefixText, int count, string contextKey)
 {

//your text box value in "prefixText" and your second argument value in "contextKey"

return Country.ToArray();

}

No comments

Leave a Reply


7 + 2 =

Categories