AspxCallBack从服务器传值到客户端单个控件可以用CallbackEventArgs的e.Result来传值,下面是传值多个控件的做法。
ASPX页面代码:
1 <dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="ASPxCallback1" OnCallback="ASPxCallback1_Callback"> 2 <ClientSideEvents CallbackComplete="OnCallbackComplete" /> 3 </dx:ASPxCallback>
<dx:ASPxTextBox ID="TextBox1" runat="server" ClientInstanceName="TextBox1" Text="TextBox1"></dx:ASPxTextBox>
<dx:ASPxTextBox ID="TextBox2" runat="server" ClientInstanceName="TextBox2" Text="TextBox2"></dx:ASPxTextBox>
JavaScript:
1 function OnCallbackComplete(s, e) { 2 TextBox1.SetValue(s.cpa);//aspxtextbox控件 3 TextBox2.SetValue(s.cpb);//aspxtextbox控件 4 }
C#代码:
1 protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) 2 { 3 e.Result = "a|b|c"; 4 ASPxCallback1.JSProperties["cpa"] = "a";//参数必须以cp开头 5 ASPxCallback1.JSProperties["cpb"] = "b"; 6 ASPxCallback1.JSProperties["cpd"] = "c"; 7 }