ajax检查用户名可用性asp.net [英] ajax check username availability asp.net

查看:81
本文介绍了ajax检查用户名可用性asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是asp.net的新手..

i希望检查用户名是否可用或不使用ajax ..

plz任何人都给我相同的代码...

plz ..

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..

推荐答案

嗨朋友!

我无法给你代码,因为我已经练习了很长时间......

但是我可以用我通常可以解释的方式来帮助你如何实现的基础知识....



在AJAX(异步JavaScript和XML)中,我们发送加载部分数据的请求。并根据需要使用它。

现在,您只需从onblur()事件或onkeyup()事件中获取文本框中的值,并将字符串即Textbox.Text发布到processor.asp页面。

这里,只需将此字符串与数据库中的所有条目进行比较。

如果找到字符串,否则返回false,返回true

使用此数据,打印文本,用户名可用或用户名不可用



如果用户名是,您还可以将提交按钮的启用状态更改为false无法使用。 :-)



我有一段代码,我是为我的一个基于PHP的网站编写的,但由于它是javascript代码,所以也许它可以是对你有所帮助.... :)



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.... :)

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;
		}
	}


PLZ任何人都给我相同的代码...

plz为asp提供代码..

否。这里的效果不一样。



以下是询问者的预期:

1. 首先尝试你想做什么!你可能会发现它并不那么难。

2.制定你所做的看似问题/不工作的事情。







目前,Tushar alreay建议如何做到这一点。

步骤:

1.为用户名文本框定义onblur / onchange客户端事件

2.输入用户名并离开文本框,客户端事件方法将被调用

3.在客户端事件方法(Javascript方法)中,创建XMLHttpRequest

4.将用户名文本作为XHR的参数传递

5.在服务器端,处理XHR并验证您的业务逻辑/需要

6.根据您的验证返回响应。

7.根据回复显示消息。



试试!
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!


只需使用Ajax Toolkit ASP.net并使用工具更新面板。在回发期间,它无需刷新您的页面。





http://www.youtube.com/watch?v=aDBlbmtqMXQ [ ^ ]
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[^]


这篇关于ajax检查用户名可用性asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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