=============================CallBack===========================
//拉一個CallBack控制項進來,設定Client的實體名稱為CallBack1,
//並在CallBack完成後觸發Client端的JavaScript去改ASPxTextBox1這個輸入控制項的值
//ASPxTextBox1_I是ASPxTextBox1在Client端的Name(可去看瀏覽器原始碼)
<dxcb:ASPxCallback ID="ASPxCallback1" runat="server" oncallback="ASPxCallback1_Callback" ClientInstanceName="Callback1">
<ClientSideEvents CallbackComplete="function(s, e)
{
document.getElementById("ASPxTextBox1_I").innerText = e.result;
}"
/>
</dxcb:ASPxCallback>
//拉一個Button設定按下去後觸發Client端的JavaScript
//也就是開始觸發CallBack這個元件
<dxe:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="CallBackTest" >
<ClientSideEvents Click="function(s, e)
{
Callback1.PerformCallback('Hello,How are you');
}
"/>
</dxe:ASPxButton>
//在觸發PerFormCallBack函示之後,便會執行Server端的CallBack事件
//e.Parameter是PerFormCallBack括號裡的值也就是Hello,How are you
//存到e.Result後會傳回去Client端就可用e.result去讀到
protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
{
e.Result = "Good" + e.Parameter;
}
=============================CallBackPanel===========================
//CallBackPanel是一個Panel裡面的值都會重新產生,所以沒有e.Result,
//只有傳過去Server端的e.Parameter,Server端收到後可直接更改TextBox的值
//但是那個TextBox要放在CallBackPanel裡才會變喔
<dxcp:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server"
ClientInstanceName="CallBackPanel" Height="84px" Width="243px"
oncallback="ASPxCallbackPanel1_Callback">
<PanelCollection>
<dxp:PanelContent runat="server">
<dxe:ASPxTextBox ID="ASPxTextBox2" runat="server" Width="170px">
</dxe:ASPxTextBox>
<br />
</dxp:PanelContent>
</PanelCollection>
<ClientSideEvents EndCallback="function(s, e)
{
}"
/>
</dxcp:ASPxCallbackPanel>
<dxe:ASPxButton ID="ASPxButton2" runat="server" Text="CallBackPanelTest"
AutoPostBack="False">
<ClientSideEvents Click="function(s, e)
{
CallBackPanel.PerformCallback('YesIam');
}
" />
</dxe:ASPxButton>
protected void ASPxCallbackPanel1_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
ASPxTextBox2.Text = "Good" + e.Parameter;
}
留言列表