如何使用c#在ajax自动完成扩展器中使用上下文密钥 [英] how to use context key in ajax autocomplete extender using c#
问题描述
创建一个Web方法,需要从文本框传递两个值,anather是前缀值
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings [ ConnectionString1]。ConnectionString;
使用(SqlCommand cmd = new SqlCommand())
{
// string cmdText =从客户中选择ContactName+
// ContactName like @SearchText +'%';
string cmdText = 从MM_Pomast内部联接MSupplier中选择MSupplier.pcode,MSupplier.pdesc on MSupplier.pcode = MM_Pomast.pcode +
其中MSupplier.loccode =' + loccode + '和MSupplier.divcode =' + divcode + '和MSupplier.cl icode =' + clicode + ' +
和pdesc类似'%'+ @ prefixText +'%';
cmd.Parameters.AddWithValue( @ prefixText,prefixText);
if (contextKey!= null )
{
cmdText + = 和MM_Pomast.pordcode = @contextKey;
cmd.Parameters.AddWithValue( @ contextKey,contextKey);
}
cmd.CommandText = cmdText;
cmd.Connection = conn;
conn.Open();
List< string> customers = new List< string>();
使用(SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(sdr [ 。pdesc跨度>]的ToString());
}
}
conn.Close();
返回客户;
}
我用这个
这个前缀值显示但是@contextKey的值没有得到
然后我在cs中使用bellow java脚本
function SetContextKey(){
$ find(' AutoCompleteExtender1')。set_contextKey($ get( <%= Drppordcode.ClientID%>)。value);
}
为特定文本框设置onkeyup,如bellow
onkeyup =SetContextKey( )
但仍然不是我在上下文键中给出的值
非常需要帮助。 。
find(' AutoCompleteExtender1')。set_contextKey(
get( <%= Drppordcode.ClientID %GT;跨度>)值);
}
为特定文本框设置onkeyup,如bellow
onkeyup =SetContextKey( )
但仍然不是我在上下文键中给出的值
非常需要帮助。
create a web method and need to pass two values one from text box and anather is prefix value
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager
.ConnectionStrings["ConnectionString1"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
//string cmdText = "select ContactName from Customers where " +
//"ContactName like @SearchText + '%'";
string cmdText = "select MSupplier.pcode,MSupplier.pdesc from MM_Pomast inner join MSupplier on MSupplier.pcode=MM_Pomast.pcode " +
" where MSupplier.loccode='" + loccode + "' And MSupplier.divcode='" + divcode + "' And MSupplier.clicode='" + clicode + "'" +
" and pdesc like '%'+@prefixText+'%'";
cmd.Parameters.AddWithValue("@prefixText", prefixText);
if (contextKey != null)
{
cmdText += " and MM_Pomast.pordcode = @contextKey";
cmd.Parameters.AddWithValue("@contextKey", contextKey);
}
cmd.CommandText = cmdText;
cmd.Connection = conn;
conn.Open();
List<string> customers = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(sdr["pdesc"].ToString());
}
}
conn.Close();
return customers;
}
where i use this
in this prefix value is showing but value of @contextKey is not getting
then i use bellow java script in cs
function SetContextKey() {
$find('AutoCompleteExtender1').set_contextKey($get("<%=Drppordcode.ClientID %>").value);
}
set onkeyup for that perticular text box like bellow
onkeyup="SetContextKey()"
but still it not me given an value at context key
need a help very..
find('AutoCompleteExtender1').set_contextKey(
get("<%=Drppordcode.ClientID %>").value); }
set onkeyup for that perticular text box like bellow
onkeyup="SetContextKey()"
but still it not me given an value at context key
need a help very..
这篇关于如何使用c#在ajax自动完成扩展器中使用上下文密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!