我的搜索框带有用户名并在用户列表中搜索 问题是我希望程序在收到用户的第一封信时直接搜索
前端
<asp:TextBox ID="TextBox1"
class="form-control table-search-input"
ontextchanged="TextBox1_TextChanged"
AutoPostBack="True"
runat="server" >
返回-完
protected void TextBox1_TextChanged(object sender, EventArgs e )
{
int bb=TextBox1.Text.Length;
adminuserlist2 = adminuserlist2.Where(o => o.AdminUserName.Substring(0,bb) == TextBox1.Text).ToList();
if (adminuserlist2 != null)
{
Table1.Rows.Clear();
Table1.BorderWidth = 1;
Table1.BorderStyle = BorderStyle.Groove;
Table1.GridLines = GridLines.Both;
TableCell un = new TableCell();
un.Text = "UserName";
TableCell pass = new TableCell();
pass.Text = "Password";
TableCell email = new TableCell();
email.Text = "Email";
TableCell isactives = new TableCell();
isactives.Text = "IsActive";
TableCell typename = new TableCell();
typename.Text = "Type Name";
TableCell typeid = new TableCell();
typeid.Text = "Type Id";
row = new TableRow();
row.Width = new Unit("120%");
row.BackColor = System.Drawing.Color.White;
row.ControlStyle.Font.Size = 25;
row.ControlStyle.Font.Bold = true;
row.ControlStyle.ForeColor = System.Drawing.Color.Black;
row.Controls.Add(un);
row.Controls.Add(pass);
row.Controls.Add(email);
row.Controls.Add(isactives);
row.Controls.Add(typename);
row.Controls.Add(typeid);
Table1.Controls.Add(row);
row.ControlStyle.Width = 300;
row.ControlStyle.Height = 30;
Table1.Width = 500;
Table1.ControlStyle.Width = 1000;
Table1.Height = 500;
Table1.CellSpacing = 50;
Table1.CellPadding = 50;
for (int i = 0; i < adminuserlist2.Count; i++)
{
TableCell un2 = new TableCell();
un2.Text = adminuserlist2[i].AdminUserName;
TableCell pass2 = new TableCell();
pass2.Text = adminuserlist2[i].AdminUserPassword;
TableCell email2 = new TableCell();
email2.Text = adminuserlist2[i].AdminUserEmail;
TableCell isactives2 = new TableCell();
isactives2.Text = adminuserlist2[i].IsActive.ToString();
TableCell typename2 = new TableCell();
typename2.Text = adminuserlist2[i].AdminUserType;
TableCell typeid2 = new TableCell();
typeid2.Text = adminuserlist2[i].AdminUserTypeID.ToString();
row = new TableRow();
row.Controls.Add(un2);
row.Controls.Add(pass2);
row.Controls.Add(email2);
row.Controls.Add(isactives2);
row.Controls.Add(typename2);
row.Controls.Add(typeid2);
Table1.Controls.Add(row);
}
}
}
我遇到了一个问题,我应该从文本框中单击进行搜索 请任何人都可以帮忙
答案 0 :(得分:0)
如果你选择try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.al.name",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
活动而不是OnKeyPress
只更改活动并且它将会正常工作
TextChanged
<asp:TextBox ID="TextBox1"
class="form-control table-search-input"
onkeypress="__doPostBack(this.name,'OnKeyPress');"
AutoPostBack="True"
runat="server" >
答案 1 :(得分:0)
在Asp.Net中没有真正的textchanged事件,只有在文本框失去焦点并且你已将autopostback设置为true时才会触发。
您可以做的是以下内容:
将ScriptManager添加到您的aspx页面:
$value = "zkjxhvzkjxcvhnzxv"""!^!^!";
$html = new simple_html_dom();
$html->load('<input type="text" id='myID'>');
$input = $html->getElementById('myID');
$input->setAttribute("value", $value);
echo $html;
在文本框中添加onkeypress clientide事件:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>
调用PageMethod:
<asp:TextBox ID="TextBox1"
class="form-control table-search-input"
ontextchanged="TextBox1_TextChanged"
AutoPostBack="True"
runat="server" onkeypress="CallMyPageMethod();" >
将PageMethod添加到您的代码后面:
<script language="javascript" type="text/javascript">
function CallMyPageMethod() {
PageMethods.MyPageMethod();
}