Variable is a control that is used to pass data between the client and the server. Variable v1.2 made the following improvements to 1.1:
(1) The ICallbackEventHandler interface is implemented to support the transfer of data between the client and the server without postback in the ASP.net Web page;
(2) Enhance the function of client variablemanager;
Variable v1.2 Use Guide: 1. Pass data between client and server (1) Send callback on client to transfer data to server
Sending a callback at the client sends the data to the server is very simple, just create a callback function and call the Variablemanager.callserver method, the following example shows how to send a callback:
<script language= "javascript" type= "Text/javascript" >//callback function, the client sends the data to the server, and when the server is processed and sent back to the client, the function is called/ Note: The callback function has no parameter function Callback () {//After receiving data from the server, display data alert (VARIABLE1)}function Btncallback_onclick () {//Modify the value of the variable Variable1={a:7,b:8,c:9}//Send callback Variablemanager.callserver (' Variable1 ', Callback)}script><cc1:variable ID= " Variable1 "runat=" Server ">cc1:variable><input id=" Btncallback "type=" button "value=" Callback "onclick=" Return Btncallback_onclick () "/> (2) The data that the server accepts the callback to receive the client
The data sent by the server processing the client only needs to handle the OnCallback event, as follows:
public partial class webusercontrol:system.web.ui.usercontrol{protected void Page_Load (object sender, EventArgs e) {if ( ! IsPostBack) {//Initialize Variable1 value variable1.value = new int] {1, 2, 3, 4};} Variable1.oncallback+=new LUCC. Variable.oncallbackdelegate (Variable1_oncallback); } protected void Variable1_oncallback (LUCC. Variable var) {//Where the value of the Variable1 sent by the client is received//the value of the Variable1 is modified in the server variable1.value= "Hello World";} (3) Effect
2. Using Variablemanager to manage variables on the client
The variable control generates a Variablemanager object on the client to manage all the variables, using Variablemanager to do the following:
RELATED Links: variable controls [update to 1.2]--transfer variables between client and server
Variable v1.2 and its source code download