Original method (missing cursor verification database)

Source: Internet
Author: User

Page code:

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
<SCRIPT type = "text/JavaScript">
Function $ (e ){
Return document. getelementbyid? Document. getelementbyid (e): NULL;
}
Function check (name ){
VaR XMLHTTP = false;
VaR url = "handler1.ashx? Name = "+ name +" & RD = "+ math. Random ();
Createxmlhttp ();
Ajax_process (URL );
}
Function ajax_process (URL ){
XMLHTTP. Open ("Post", URL, true );
XMLHTTP. onreadystatechange = ajax_sumbitemployment;
XMLHTTP. Send (null );
Function ajax_sumbitemployment (){
If (XMLHTTP. readystate = 4 ){
If (XMLHTTP. Status = 200 ){
If (XMLHTTP. responsetext = "validatenull "){
$ ('Label1'). innertext = "the user name cannot be blank! ";
Return;
}

If (XMLHTTP. responsetext = "smalllength "){
// $ ('Label1'). innertext = "cannot be less than 2 Characters! ";
Alert ("5432323 ");
Return;
}
If (XMLHTTP. responsetext = "exist "){
$ ('Label1'). innertext = "the user name already exists. Please select another user name! ";
Return;
}
Else {
$ ('Label1'). innertext = "Congratulations, you can use the user name! ";
}
}
}
}
}
// Create an Ajax object
Function createxmlhttp (){
Try {XMLHTTP = new activexobject ("msxml2.xmlhttp ");}
Catch (e ){
Try {XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");}
Catch (e ){
Try {XMLHTTP = new XMLHttpRequest ();}
Catch (e) {XMLHTTP = false ;}
}
}
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: Label id = "label1" runat = "server" text = "label"> </ASP: Label>
<Asp: textbox id = "txtusernaem" runat = "server" onblur = "Return check (this. Value)"> </ASP: textbox>

<Asp: textbox id = "textbox1" runat = "server"> </ASP: textbox>
</Div>
</Form>
</Body>
</Html>

Processing file: handler1.ashx

  public class Handler1 : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
string Name = context.Request.QueryString["Name"];
if (!String.IsNullOrEmpty(Name))
{
if (Name.Length < 2)
{
context.Response.Write("smallLength");
}
else
{
context.Response.Write("exist");
}

// Maticsoft.BLL.Personnel person = new Maticsoft.BLL.Personnel();
// Maticsoft.Model.personnelDate personDate = person.GetModel(Name);

//if (personDate != null)
//{
// context.Response.Write("exist");
//}
}
else
{

context.Response.Write("validateNull");
}

}

public bool IsReusable
{
get
{
return false;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.