Click here to Skip to main content
16,008,075 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i m new to asp.net..
i want to check username is available or not using ajax..
plz anyone give me code for the same...
plz..
Posted

Just use Ajax Toolkit of ASP.net and use the tool Update Panel. It works without refreshing your page during post back.


http://www.youtube.com/watch?v=aDBlbmtqMXQ[^]
 
Share this answer
 
v2
plz anyone give me code for the same...
plz give code for asp..
No. It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.



For now, Tushar alreay suggested on how it can be done.
Steps:
1. Define a onblur/onchange client event for the username textbox
2. Once you enter the username and leave the textbox, above client event method will be called
3. In the client event method (Javascript method), create a XMLHttpRequest
4. Pass on the username text as parameter of XHR
5. On server side, process the XHR and verify your business logic/need
6. Return back response based on your verification.
7. Display message based on response.

Try!
 
Share this answer
 
Hi Friend!
I am unable to give you codes since I haven't practiced it for so long...
but I can help you in the way that I can generally explain the basics of how can it be implemented....

In AJAX (Asynchronous JavaScript and XML), we send a request to load a partial piece of data. and use it as required.
Now here, you simply take the value from textbox either on onblur() event or onkeyup() event and post the string ie Textbox.Text to a processor.asp page.
Here, simply compare this string with all the entries present in the database.
If you found the string, return false otherwise, return true
use this data, to print a text, "Username available" or "Username not available"

You can also change the submit button's enable state to false if username is not available. :-)

I have a piece of code, I had written it for one of my PHP based website, but since it is javascript code, so maybe it can be of some help to you.... :)

JavaScript
function chkmatch(str)
	{
		var test = document.frm.password.value;
		if(str!="")
		{
			if(test==str)
			{
				document.getElementById("getmatch").innerHTML = "<font color="green">Password Matched</font>";
				document.frm.register.enable = true;
			}
			else
			{
				document.getElementById("getmatch").innerHTML = "<font color="red">Password Didn't Matched</font>";
				document.frm.register.enable = false;
			}
		}
		else
		{
			document.getElementById("getmatch").innerHTML = "";
			document.frm.register.enable = false;
		}
	}
 
Share this answer
 
Comments
Member 9332883 15-Sep-12 12:13pm    
plz give code for asp..

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