
June 29, 2010 04:31 by
This link points to code that shows you how to use the context key on an asp.net autocompleteextender control
example
sample C# and asp code
aspx page
<cc1:AutoCompleteExtender runat="server" ID="AutoCompleteExtender1" TargetControlID="txtAccount"
ServiceMethod="GetAccount" ServicePath="ProductsWS.asmx" MinimumPrefixLength="1"
ContextKey="Admin" UseContextKey="true"
CompletionInterval="200" EnableCaching="true">
</cc1:AutoCompleteExtender>
aspx code behind
if (!IsPostBack)
{
//set key to user name unless user is admin
if (Convert.ToBoolean(Session["isMasterAccount"].ToString()) == true)
{
AutoCompleteExtender1.ContextKey = "Admin";
}
else
{
AutoCompleteExtender1.ContextKey = Session["Name"].ToString();
}
}
asmx page
[WebMethod]
public string[] GetAccount(string prefixText, int count, string contextKey)
{
//filter list of accounts by person logged in.
DAL dLayer = new DAL();
string uName = contextKey;
return dLayer.GetAccount(prefixText, uName).ToArray();
}
951b4dae-1034-4310-9f20-2dbac98404fb|1|5.0