1,ConfigurationWeb. config
<System. Web>
<Httphandlers>
<Add verb = "post, get" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro.2"/>
</Httphandlers>
</System. Web>
2. Add reference ajaxpro.2.dll
3. BackgroundCodeAs follows:
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using ajaxpro;
Namespace used_car
{
Public partial classWebform1: System. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Ajaxpro. Utility. registertypeforajax (typeof (Webform1), This. Page );
}
[Ajaxpro. ajaxmethod]
Public String getservertime ()
{
Return datetime. Now. tostring ();
}
}
}
4. frontend call
<Script language = "JavaScript" type = "text/JavaScript">
Function testf (){
VaR dt = used_car.webform1.getservertime ().Value;
Alert (DT );
}
</SCRIPT>
<Input id = "comit" type = "button" value = "OK" onclick = "testf ()"/>