Click here to Skip to main content
Sign Up to vote bad
good
See more: C#ASP.NET
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 15 Sep '12 - 5:20


2 solutions

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. Smile | :)
 
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.... Smile | :)
 
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;
		}
	}
  Permalink  
Comments
Member 9332883 - 15 Sep '12 - 12:13
plz give code for asp..
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!
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 273
1 Sergey Alexandrovich Kryukov 254
2 Maciej Los 136
3 Richard MacCutchan 125
4 Zoltán Zörgő 90
0 Sergey Alexandrovich Kryukov 10,264
1 OriginalGriff 7,917
2 CPallini 4,181
3 Rohan Leuva 3,522
4 Maciej Los 3,125


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 15 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid