asp.net如何验证用户名已存在 textbox控件,如何做输入验证 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 textbox失去焦点时ajax发送到服务器,查询数据库,再把查询结果返回,用js判断显示相关信息。 textbox后放一“验证用户”button,输入完用户名后点击验证。 要么JS 或JQ 简单点:直接拖个AJAX 异步刷新 后台直接判断 <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate><table>//放个Label显示信息 ,后台直接数据库判断,存在则显示 不存在则隐藏。</table> </ContentTemplate> </asp:UpdatePanel> 建议用jquery ajax,方便,简单。 ajax + js参考这个: http://www.w3school.com.cn/ajax/ajax_asp_php.asp textbox失去焦点时,查询数据库中有没有输入的用户名。 string myConnectionString = "Initial Catalog=dengru;Data Source=localhost;Integrated Security=SSPI;"; myConnection = new SqlConnection(myConnectionString); cmd = new SqlCommand(); cmd.Connection = myConnection; myConnection.Open(); string sql; sql = "select user from dr where ID='" + textBox1.Text.Trim() + "' and PassWord= '" + textBox2.Text.Trim() + "'"; cmd.CommandText = sql; if (cmd.ExecuteScalar() != null) { //存在 } 微软对自己那个Membership已经提供了Web Service供js客户端调用了。还包括Role, Profile等。 还是建议用 JQ 的 ajax 现在的 ajax 用处很多 XMLHttpRequest实现无刷新验证用户名 http://blog.csdn.net/sandy945/article/details/4169870 把用户名传进数据库进行查找对象,如为NULL,则没有,否则,有。在数据访问层查找,在逻辑层判断 关于类对象的疑问 急求解决打印预览问题!!!!!!! 数组问题 请帮忙解决下,谢谢 一个窗体关闭后使另一个窗体刷新是怎么做的? 异步http请求问题 高分:执行TLBIMP后的msword.dll文件还是不能加入的COM组件! 请教!各位高手!!!有关C#做聊天游戏的问题! C#的构造函数问题,简单 如何将一个access数据库的各个列绑定在窗口中的各个控件上? c#基本语法已搞懂 C#操作Excel表格 webBrowser打开新winform窗体
要么JS 或JQ 简单点:
直接拖个AJAX 异步刷新 后台直接判断
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table>
//放个Label显示信息 ,后台直接数据库判断,存在则显示 不存在则隐藏。
</table> </ContentTemplate>
</asp:UpdatePanel>
string myConnectionString = "Initial Catalog=dengru;Data Source=localhost;Integrated Security=SSPI;";
myConnection = new SqlConnection(myConnectionString);
cmd = new SqlCommand();
cmd.Connection = myConnection;
myConnection.Open();
string sql;
sql = "select user from dr where ID='" + textBox1.Text.Trim() + "' and PassWord= '" + textBox2.Text.Trim() + "'";
cmd.CommandText = sql;
if (cmd.ExecuteScalar() != null)
{
//存在
}