1. Front-end page:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<SCRIPT type = "text/JavaScript">
VaR XMLHTTP;
Function createxmlhttprequest ()
{
If (window. activexobject)
{
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest)
{
XMLHTTP = new XMLHttpRequest ();
}
}
Function addnumber ()
{
Createxmlhttprequest ();
VaR url = "handler. ashx? Num1 = "+ document. getelementbyid (" num1 "). Value +" & num2 = "+ document. getelementbyid (" num2 "). value;
XMLHTTP. Open ("get", URL, true );
XMLHTTP. onreadystatechange = showresult;
XMLHTTP. Send (null );
}
Function showresult ()
{
If (XMLHTTP. readystate = 4)
{
If (XMLHTTP. Status = 200)
{
Document. getelementbyid ("result"). value = XMLHTTP. responsetext;
}
}
}
</SCRIPT>
</Head>
<Body>
<Div>
<Input type = "text" id = "num1" value = "7"/> <br/>
<Input type = "text" id = "num2" value = "8"/> <br/>
<Input type = "text" id = "result"/> <br/>
<Input type = "button" name = "fdfds" value = "calculation" onclick = "addnumber ();"/>
</Div>
</Body>
</Html>
2. Computing page:
<% @ Webhandler Language = "C #" class = "handler" %>
Using system;
Using system. Web;
Using system. text;
Public class handler: ihttphandler {
Public void processrequest (httpcontext context ){
Context. response. contenttype = "text/plain ";
Int result = convert. toint32 (context. Request. querystring ["num1"]) + convert. toint32 (context. Request. querystring ["num2"]);
Context. response. Write (result );
}
Public bool isreusable {
Get {
Return false;
}
}
}