ASP.NET 2.0, no refresh page

xiaoxiao2021-03-06  93

Seeing an application example of a brushless page today. I feel good. Go back home to find out this information. "Non-refresh page" is just an inactive effect description (there are other methods To achieve this effect), more precise statements are: Use JavaScript to call a method of the server side on the page and process the returned data. Implementing its most standard method is of course XMLHTTP. However, programmers are lazy guys, everyone wants to have more convenient methods, or better packaging. For example, Lostinet's Rane is a good packaging for XMLHTTP. Finally, in ASP.NET 2.0, we can easily do this. Server-side Any control of the System.Web.ui.ICALLBACKEVENTHANDLER interface can be processed from the request and data passed from the JS script on the page through the RaiseCallBackevent () method, and then transfer the result back to the page. The bottom layer of this ability is still XMLHTTP. Here is a simple presentation: On the page, we put two text boxes and a button: When the button is clicked, the JS script method CALLTOSERVER (), the JS script is as follows: function calltoServer () {var param = document.getlementByid ("txtusername"). Value ; var context = ""; <% = ClientScript%> <% = ClientScript%>} function handleResultFromServer (result, context) {document.getElementById ( "txtResult") value = result;.} handleResultFromServer () method is responsible from The data transferred by the server is written to the TXTRESULT text box. Look server code: public partial class Default_aspx: System.Web.UI.ICallbackEventHandler {private String ClientScript {get {return this.GetCallbackEventReference (this, "param", "handleResultFromServer", "context");}}

转载请注明原文地址:https://www.9cbs.com/read-105700.html

New Post(0)