Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi...
i have inserted already some datas...
i am going to register a new user...
but i given same user name which is already inserted...
but the user name is the primary key.. so it show doesn't allows duplicate key....
how can i intimate at the textbox changed position?
is it possible to say that "please choose another username because its already chosen"...
Posted

it is easy task

use this query before inserting into table

select count(*) from yourusertable where userid='userid'

if Query return is greater than zero then user already exists :)
 
Share this answer
 
Comments
Raghupathiraja 5-Nov-11 2:25am    
thank... when the control moves to next textbox... there itself i want to do this process...
Further to above Answer, You can do validation on onchange Event of your TextBox using Ajax.
ASP.NET
<asp:textbox id="txtName" runat="server" onchange="javascript: Test();" />

You can refer my Tip/Trick for "Asp.Net Ajax".
Simplifying-Asp-Net-Core-Ajax

Updated - Or use onblur JavaScript Event.
ASP.NET
<asp:textbox id="txtName" runat="server" onblur="javascript: Test();" />
 
Share this answer
 
v2
Comments
Raghupathiraja 5-Nov-11 2:38am    
i can't get this...
RaisKazi 5-Nov-11 2:44am    
Ok. Lets go Step by Step.
1) You want to do validation of UserId whenever User change it.
2) Now Events by which you will come to know User is changing/changed UserId are Javascript Events - Either use onblur/onchange.
3) But your validation code requires server-side(code-behind).
4) If you refref my Tip/Trick link, in that I have demonstrated how you can call server-side(code-behind) from JavaScript Events.

Hope this helps. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900