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