如果UserName已存在,则在新注册时显示POPUP消息。 [英] Display a POPUP Message while new registration, if the UserName Already Exists.

查看:121
本文介绍了如果UserName已存在,则在新注册时显示POPUP消息。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello亲爱的Code Project朋友,



新注册时显示POPUP消息,如果UserName已经存在。

- -------------------------------------------------- ---------------------



我正在使用(C#,Asp。)在Asp.Net项目上工作。 Net,SqlServer 2005数据库)



我创建了一个项目。几乎完成了



目前我已经创建了一个注册页面,用于添加新用户来访问我的项目。



此用户将使用他们的用户名和密码登录项目。



只有管理员才有权创建新用户



所以我的要求是................



我在这个注册中有10个文本框页。这些是我的领域..

FN,LN,用户名,密码,部门,指定,EmailAddress,MobileNo,IssueDate,ExpiryDate。



所以当我点击UserName并在USERNAME文本框中输入已存在的用户名时...自动显示弹出消息。(UserName已经存在,请尝试另一个)





输入UserName Textbox时,如果没有点击提交按钮,则应显示此消息。



请帮忙。



先谢谢。

解决方案

我认为这就是你要找的;

< a href =http://www.dotnetspark.com/kb/1278-check-username-availability-from-database.aspx>检查数据库的用户名可用性 [ ^ ]

-or -



更好的链接: http://bit.ly/ZDo9Pj [ ^ ] :)



祝你好运,

OI


hii buddy



为此你必须在文本框控件的text_changed事件上编写代码。就像这样



  protected   void  TextBox1_TextChanged( object  sender, EventArgs e)
{

String str = 从tablename中选择UserName,其中UserName =' + textbox1.text + ;
Sqlconnection con = new sqlconnection();
Sqlcommand cmd = new sqlcomman(str,con)
con.open();

if (dr.read())
{
Response.Write( < script language = JavaScript > alert('UserName已存在,尝试另一个')< / script>);
}
else
{
Response.Write( < script language = JavaScript >提醒('用户名可用,请继续')< / script>);
}
con.close();
}



如果发生任何错误,请在下方注释,并确保从后端到前端的正确连接方法

乐于助人..


检查这个。用这个和它的工作正常





http:/ /www.dotnetspark.com/kb/Content.aspx?id=1278

Hello My dear Code Project Friends,

Display a POPUP Message while new registration, if the UserName Already Exists.
-------------------------------------------------------------------------

Am working on Asp.Net Project using (C#, Asp.Net, SqlServer 2005 Database)

I have created a Project. its almost finish

Presently I have created a Registration Page for adding New Users to Access my Project.

This Users will access the project with login, with their Username and Password.

Only Administrator has the permissions to create new user

So my requirement is................

I have 10 Textboxes in this registration page. and these are my fields..
FN, LN, UserName,Password,Department,Designation,EmailAddress,MobileNo,IssueDate,ExpiryDate.

so when i click on UserName and enter already existing username in USERNAME textbox...Automatically it should display a popup message.like (UserName Already Exists, Try another)


This message should be displayed while entering into UserName Textbox not after submit button click.

Please help.

Thanks in Advance.

解决方案

I think this is what you are looking for;
Check username availability from database[^]
-or-

Better link : http://bit.ly/ZDo9Pj[^] :)

Good luck,
OI


hii buddy

for this you have to write code on text_changed event of text box control..like this

protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

String str="select UserName from tablename where UserName='"+textbox1.text+"'";
Sqlconnection con=new sqlconnection();
Sqlcommand cmd=new sqlcomman(str, con)
con.open();

if(dr.read())
{
Response.Write("<script language="JavaScript">alert('UserName Already Exists, Try another')</script>");
}
else
{
Response.Write("<script language="JavaScript">alert('UserName Available, Please proceed')</script>");
}
con.close();
    }


if any error occurs comment below and be ensure for proper connection method from back end to front end
happy to help..


Check this.Am using this and its working fine


http://www.dotnetspark.com/kb/Content.aspx?id=1278


这篇关于如果UserName已存在,则在新注册时显示POPUP消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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