在asp.net中自动建议文本框 [英] auto suggest textbox in asp.net
本文介绍了在asp.net中自动建议文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我输入一个带有uid的文本框当我输入一个数字显示我在sqlserver数据库中的内容而不使用ajax,jQuery,只使用asp.net,C#请任何人都可以帮助...
我在页面加载下编写代码..
protected void Page_Load( object sender,EventArgs e)
{
string keyword =请求[ K跨度>];
string 模式=请求[ 模式 跨度>];
string ReturnTextbox =请求[ TB 跨度>];
string MyDiv =请求[ MyDiv 跨度>];
if (keyword!= null && Mode!= null && keyword.Trim()。Length > 0 )
{
string sql = 跨度>;
if (Mode == uid )
{
sql = SELECT Distinct TOP 5 uid FROM tbuser ORDER BY UID跨度>;
}
其他
{
return ;
}
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection();
conn = new SqlConnection(ConfigurationManager.ConnectionStrings [ kuviConnectionString跨度>]的ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter(sql,conn);
adapter.Fill(ds);
if (ds!= null && ds.Tables.Count > 0 )
{
DataTable dt = new DataTable();
dt = ds.Tables [ 0 ];
foreach (DataRow row in dt.Rows)
{
string mydata = row [ 0 ]。ToString();
if (ReturnTextbox!= null && ReturnTextbox.Trim()。Length < span class =code-keyword>> 0 )
{
// 写入默认页面,带有选择选项。
if (MyDiv == null || MyDiv.Trim()。Length == 0 )
{
Response.Write( <divönmouseover= \ this.style.cursor =指针 pointer = mode = h old = /> önclick= \ < span class =code-string> mydata = mydiv = >< font size = 2 face = Tahoma > + mydata + < / font> + );
}
}
else
{
Response.Write( < div>< font size = 2 face = Tahoma > + mydata + < / font> ;< / DIV>中跨度>);
}
}
}
}
}
解决方案
For自动建议过程更好你尝试下面的链接:
AJAX AutoComplete / AutoSuggest TextBox [ ^ ]
http:// www.asp.net/ajaxLibrary/act_AutoComplete_Simple.ashx [ ^ ]
推荐此链接
http://www.aspdotnet-suresh.com/2012/03/jquery-ui-autocomplete-textbox-with.html [ ^ 一>
I have a textbox with uid when i enter a one number showing the list what i have in the sqlserver database without using ajax,jQuery, only using asp.net,C# please anyone can help...
I''m writing a code under page load..
protected void Page_Load(object sender, EventArgs e)
{
string keyword = Request["k"];
string Mode = Request["Mode"];
string ReturnTextbox = Request["TB"];
string MyDiv = Request["MyDiv"];
if (keyword != null && Mode != null && keyword.Trim().Length > 0)
{
string sql = "";
if (Mode == "uid")
{
sql = "SELECT Distinct TOP 5 uid FROM tbuser ORDER BY uid";
}
else
{
return;
}
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection();
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["kuviConnectionString"].ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
adapter.Fill(ds);
if (ds != null && ds.Tables.Count > 0)
{
DataTable dt = new DataTable();
dt = ds.Tables[0];
foreach (DataRow row in dt.Rows)
{
string mydata = row[0].ToString();
if (ReturnTextbox != null && ReturnTextbox.Trim().Length > 0)
{
//Write to default page, with selection options.
if (MyDiv == null || MyDiv.Trim().Length == 0)
{
Response.Write("<div önmouseover="\" this.style.cursor="pointer" pointer=" mode=" hold=" /> " önclick="\" mydata="" mydiv=""><font size="2" face="Tahoma">" + mydata + "</font>" + "");
}
}
else
{
Response.Write("<div><font size="2" face="Tahoma">" + mydata + "</font></div>");
}
}
}
}
}
解决方案
For Auto suggestion process better u try below links:
AJAX AutoComplete/AutoSuggest TextBox[^]
http://www.asp.net/ajaxLibrary/act_AutoComplete_Simple.ashx[^]
Refer this Link
http://www.aspdotnet-suresh.com/2012/03/jquery-ui-autocomplete-textbox-with.html[^]
这篇关于在asp.net中自动建议文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文