开发者

AutoSuggest in a asp.net using Ajax controls

I am trying to do auto suggest in a TextBox and I used Ajax controls to do so. I am giving movies array some values. I want to give that value from the database by filtering the user table with the email Id that the User used to Login to the website. I am not able to call the Label value into the method below. I have stored the email id of user in label during page load. help me to do that.

[System.Web.Services.WebMethodAttribute(),System.Web.UI.WebControls, System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
   // Create array of movies
    string[] movies = {"Joey", "Joester", "Joker", "Joeic", "Joic", "Shrek II"};

    //开发者_C百科 Return matching movies
    return (from m in movies where m.StartsWith(prefixText,StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray();
}


If you are using the AJAX Control Toolkit you can see example here.

I am not sure what is the label about, but you need to set UseContextKey=true; and specify the context key for the ajaxToolkit:AutoCompleteExtender

In your case you can add the following code to Page.Load:

if(!Page.IsPostBack)
{
  AutoCompleteExtenderID.ContextKey = LabeWtihEmal.Text;
}


It's because the web method is static. On the load of your page, set the context key for your AutoCompleteExtender to the label value (email id). Also, make sure that UseContextKey is set to true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜