<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "SumNumber. aspx. cs" Inherits = "SumNumber" %>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> example of sum without refreshing </title>
<Script type = "text/javascript">
Var xmlHttp;
Function createXMLHttpRequest ()
{
If (window. ActiveXObject)
{
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest)
{
XmlHttp = new XMLHttpRequest ();
}
}
// Processing Method
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 );
}
// Callback Method
Function ShowResult ()
{
If (xmlHttp. readyState = 4)
{
If (xmlHttp. status = 200)
{
Document. getElementById ("sum"). value = xmlHttp. responseText;
}
}
}
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div style = "text-align: center">
<Br/> simple example of the operation of the brushless NEX algorithm <br/>
<Br/>
<Input id = "num1" style = "width: pixel PX" type = "text" onkeyup = "AddNumber ();" value = "0"/>
+ <Input id = "num2" style = "width: 95px" type = "text" onkeyup = "AddNumber ();" value = "0"/>
= <Input id = "sum" style = "width: 97px" type = "text"/> </div>
</Form>
</Body>
</Html>
This instance also uses a program to process files. The Code is as follows:
<% @ WebHandler Language = "C #" Class = "Handler" %>
Using System;
Using System. Web;
Using System. Data;
Using System. Data. SqlClient;
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;
}
}
}