Text validation on ajax autocomplete extender
I'm having a text-box with AJAX auto-complete extender. Some times when
user type some characters and presses tab key in that case web-service is
not working. How can i stop user to leave control without completion of
service method.
.aspx Code
<asp:TextBox runat="server" ID="ddlOrg" CssClass="tb10" autocomplete="off" />
<ajaxToolkit:AutoCompleteExtender
TargetControlID="ddlOrg" UseContextKey="true"
runat="server" BehaviorID="AutoCompleteEx"
ID="autoComplete1"
ServicePath="AutoComplete.asmx"
ServiceMethod="GetResellerList"
MinimumPrefixLength="1"
CompletionInterval="1000" EnableCaching="true"
FirstRowSelected="true"
CompletionSetCount="20"
CompletionListCssClass="cssList"
DelimiterCharacters=""
ShowOnlyCurrentWordInCompletionListItem="true" >
</ajaxToolkit:AutoCompleteExtender>
Service Code
[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();
}
Can any one help me to do this.
No comments:
Post a Comment