开发者

Auto suggest using AJAX Control Toolkit, pass value to array

This is for auto suggest using AJAX Control Toolkit I am creating a session and passing the value to this page through page load

 protected void Page_Load(object sender, EventArgs e)
    {
        if
            (Session["useremail"] == null) Response.Redirect("Home.aspx");
        else
            Label8.Text = Session["useremail"].ToString();
    }

I want to use the label8.text value in the method below so that I can use that to query the database and give the result(Firstname from user table) from database to the array movies.

[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string[] GetCompletionList(string prefixText, int count, string 开发者_Go百科contextKey)
    {  
        string[] movies = { "Joey", "Joester", "Joker", "Joeic", "Joic", "Shrek II" };

        return (from m in movies where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray();
    }

Please tell me how to pass the firstname value from table user to the array.


You need to make an AJAX call, using an UpdatePanel, that has your WebService as its endpoint. You can set up an AsyncTrigger as shown in here that passes to a code behind which reads the value of the label's text and calls the web service. If you're using MVC, the approach is a bit different. This may help with that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜