C # code
Public partial class _ Default: System. Web. UI. Page, ICallbackEventHandler
...{
Private string result;
Protected void Page_Load (object sender, EventArgs e)
...{
If (! Page. IsPostBack)
...{
String cbReference = Page. clientScript. getCallbackEventReference (this, "text", "ReceiveServerData", ""); // gets a reference to a client function. When this function is called, calls back a client that starts a server-side event.
String callbackScript = "function dos (text) {" + cbReference + ";}"; // Method for registering a client
Page. ClientScript. RegisterClientScriptBlock (this. GetType (), "dos", callbackScript, true );
}
}
Public void RaiseCallbackEvent (string text)
...{
If (text [0] = 'C ')
...{
String checkcode = (string) Session ["validateCode"];
String j = text. Substring (1 );
Checkcode = checkcode. ToLower ();
J = j. ToLower ();
If (j = checkcode)
Result = "ctrue ";
Else
Result = "cfalse ";
}
Else if (text [0] = 'E ')
...{
String j = text. Substring (1 );
LinkDataBase myLink = new LinkDataBase ();
If (mylink. checkemail (j) = 1)
Result = "efalse ";
Else
Result = "etrue ";
}
Else if (Text [0] = 'U ')
...{
String J = text. substring (1 );
Linkdatabase mylink = new linkdatabase ();
If (mylink. checkuser (j) = 1)
Result = "ufalse ";
Else
Result = "utrue ";
}
}
Public String getcallbackresult ()
...{
Return result;
}
}
Add the following functions to javascript:
Function compute eserverdata (text)
...{
If (text = "cfalse ")
...{
Checkvalidatecode = "false2 ";
Setcheckvalidatecode (checkvalidatecode );
}
Else if (text = "ctrue ")
...{
Checkvalidatecode = "true ";
Setcheckvalidatecode (checkvalidatecode );
}
Else if (text = "etrue ")
...{
Checkemail = "true ";
Setcheckemail (checkemail );
}
Else if (text = "efalse ")
...{
Checkemail = "false3 ";
Setcheckemail (checkemail );
}
Else if (text = "ufalse ")
...{
Checkuser = "false4 ";
Setcheckuser (checkuser );
}
Else if (text = "utrue ")
...{
Checkuser = "true ";
Setcheckuser (checkuser );
}
Checking = false;
}
Finally, it is called using dos (str) in Javascript.