<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Default. aspx. CS " Inherits = " _ Default " %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > Untitled page </ Title >
< Script >
Function Calltoserver ()
{
VaR Param = Document. getelementbyid ( " Txtmessage " ). Value;
VaR Context = "" ;
<% = Blientscript %>
}
Function Handleresultfromserver (result, context)
{
Document. getelementbyid ("Txtresult"). Value=Result;
}
</ Script >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >
< Input ID = "Txtmessage" />
< Input Onclick = "Calltoserver ();" Type = "Button" Value = "Call to server" ID = "Button1" />
Result: < Input ID = "Txtresult" />
</ 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 _ Default: system. Web. UI. Page, system. Web. UI. icallbackeventhandler
{
Protected Void Page_load ( Object Sender, eventargs E)
{
}
Protected String blientscript
{
Get
{< br> return This . clientscript. getcallbackeventreference ( This , " param " , " handleresultfromserver " , " context " );
}
}
Public String Raisecallbackevent ( String Eventargument)
{
Return " The client [ " + Datetime. Now. tostring () + " ] Sent [ " + Eventargument + " ]. " ;
}
}
It turns out that the author cannot pass debugging... it should be like this...
Return This. Clientscript. getcallbackeventreference (This,"Param","Handleresultfromserver","Context");//This should be done in (Asp.net beta2)
// Reference
http://blog.joycode.com/kaneboy/archive/2004/07/07/26914.aspx