的AutoSuggest使用Ajax控件一个asp.net [英] AutoSuggest in a asp.net using Ajax controls

查看:126
本文介绍了的AutoSuggest使用Ajax控件一个asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做自动提示在文本框我用阿贾克斯控件来做到这一点。我给电影数组中的值。我想通过过滤用户表与用户用来登录该网站的电子邮件ID给从数据库中值。我不能够调用标签值到下面的方法。在页面加载我已存储的用户标识的电子邮件ID。帮我做到这一点。

  [System.Web.Services.WebMethodAttribute(),System.Web.UI.WebControls,System.Web.Script.Services.ScriptMethodAttribute()]
公共静态字符串[] GetCompletionList(字符串prefixText,诠释计数,串contextKey)
{
   //创建电影阵列
    字符串[]电影= {乔伊,Joester,小丑,Joeic,Joic,怪物史莱克II};

    //返回匹配的电影
    回报(从米影片,其中m.StartsWith(prefixText,StringComparison.CurrentCultureIgnoreCase)选择M)。取(计数).ToArray();
}
 

解决方案

如果您正在使用AJAX控件工具包,你可以看到的例子的这里

我不知道什么是对的标签,但你需要设置 UseContextKey = TRUE; 并指定 ajaxToolkit的背景下键: AutoCompleteExtender

在你的情况,你可以添加以下code到Page.Load:

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

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"};

    // 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;
}

这篇关于的AutoSuggest使用Ajax控件一个asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆