Recently I read about ajax pro, because this method is used when WebPhone is to be developed,
WebpHone is a page that can be used to go to MakeCall on the Web. The process is to provide a method for MakeCall to be sent to the Agent or to the user through automatic dialing when the user wants to contact the customer, connect to the Agent after connection. of course, this requires hardware support.
Here I will just talk about a method to call the background at the front end. The Ajax Pro method is used. As for the background processing process, it is too troublesome to skip it.
1. Introduce ajax. dll into the project.
2. Modify the Web. config file and add the following content to the System. web node:
<HttpHandlers>
<Add verb = "POST, GET" path = "ajax/*. ashx" type = "Ajax. PageHandlerFactory, Ajax"/>
</HttpHandlers>
3. Add Ajax support in the Page_Load method of the page to be used. And write a simple method, and mark the attribute of the method as AjaxMethod.
Public partial class Demo: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Ajax. Utility. RegisterTypeForAjax (typeof (Demo ));
}
[Ajax. AjaxMethod (Ajax. HttpSessionStateRequirement. Read)]
Public int LogIn (string userName, string Pwd)
{
Return 0;
}
}
4. page call, where Login_CallBack is the callback method. Of course, the asynchronous method is used here. You can also use the synchronous method, as long as the synchronous party calls LogIn, do not include callback. If the call process is long, you should use an asynchronous method. After the call, you can display a loading and wait for the return. After the result is returned, go to the Update page.
Function IMG1_onclick (){
Var userName = $ ("Username"). value;
Var userpwd = $ ("Password"). value;
Demo. LogIn (userName, userpwd, Login_CallBack );
}
Function Login_CallBack (response)
{
If (response. error! = Null)
{
Alert (response. error );
Return;
}
Var states = response. value;
If (states = null)
{
Return;
}
If (states = 0)
{
Window. location = "Default. aspx ";
}
}