Front-end <% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Callbackexample. aspx. CS " Inherits = " Ajax_callbackexample " %>
<!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 " >
Function callserver (inputcontrol, context)
{
Context. innerhtml = " Loading .. " ;
ARG = Inputcontrol. value;
<% = Clientscript. getcallbackeventreference ( This , " ARG " , " Receiveserverdata " , " Context " ) %> ;
}
Function compute eserverdata (result, context)
{
Context. innerhtml = Result;
}
</ Script >
</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< Div >
< ASP: textbox ID = " Textbox1 " Runat = " Server " > </ ASP: textbox >
< Input ID = " Button1 " Type = " Button " Onclick = " Callserver (textbox1, label1) " Value = " Button " />
< ASP: Label ID = " Label1 " Runat = " Server " Text = " Label " > </ ASP: Label >
</ Div >
</ Form >
</ Body >
</ Html >
Using System;
Using System. Data;
Using System. configuration;
Using System. collections;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Web. UI. webcontrols. webparts;
Using System. Web. UI. htmlcontrols;
Public Partial Class Ajax_callbackexample: system. Web. UI. Page, system. Web. UI. icallbackeventhandler
{
Private String Result;
Protected Void Page_load ( Object Sender, eventargs E)
{
}
Public Void Raisecallbackevent ( String Eventargument)
{
Result= "Return from server"+Eventargument;
}
Public String Getcallbackresult ()
{
ReturnResult;
}
}
ASP. NET 2.0 client callback