Ajax|ajax Framework
This article is just a basic AJAX framework, although AJAX is not a new technology, but as a framework is not an article can explain the white. The purpose of this article: to help beginners learn better and use the AJAX framework.
I always believe that only if you really understand a technology and understand the technology itself can you use it better and more flexibly. A programmer's understanding of technology cannot be confined to the application of technology.
Environment: Window Xp SP2 +. Net framwwork 2.0.50727.
asp.net 2.0 self-brought client callback
ASP.net 2.0 has been released. 2.0 has many new features, and the client callback is one of them. The client callback allows us to invoke the server-side method without a postback, which is consistent with the functionality provided by Ajax, but not as flexible as Ajax, where Ajax can customize the calling method, with 2.0 of its own callback capabilities.
The System.Web.UI.IcallbackEventHandler interface must be implemented to use the client callback feature.
This interface contains two methods:
Fixed call this method when client callback public void RaiseCallbackEvent (String eventargument) This method is called after the raisecallbackevent has been executed. The return value of this method is sent back to the client public string GetCallbackResult () |
Example one:
. CS: String cbreference = Page.ClientScript.GetCallbackEventReference (This, "Arg", "receiveserverdata", "context"); String Callbackscript; Callbackscript = "function CallServer (ARG, context)" + "{" + Cbreference + "};"; Page.ClientScript.RegisterClientScriptBlock (this. GetType (), "CallServer", Callbackscript, True); Javascript: <script type= "Text/javascript" > function LookUpStock () { var product = ""; var lb = document.forms[0]. ListBox1; if (lb.selectedindex >= 0) Product = Lb.options[lb.selectedindex].text; CallServer (Product, ""); } function Receiveserverdata (rValue) {results.innertext = RValue;} </script> |
See MSDN for more information.
[1] [2] Next page