0
如何在devexpress中的asp.net中多次調用客戶端回調函數。在asp.net中多次調用客戶端回調函數devexpress
這裏是頁面加載事件:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsCallback)
return;
//Creating a reference of Client side Method, that is called after callback on server
String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg","ReceiveServerData", "");
//Putting the reference in the method that will initiate Callback
String callbackScript = "function CallServer(arg, context) {" +cbReference + "; }";
//Registering the method
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"CallServer", callbackScript, true);
}
public void RaiseCallbackEvent(String eventArgument)
{
DateTime dob = Convert.ToDateTime(eventArgument);
DateTime Today = DateTime.Now;
TimeSpan ts = Today - dob;
DateTime Age = DateTime.MinValue + ts;
int Years = Age.Year - 1;
int Months = Age.Month - 1;
int Days = Age.Day - 1;
result = Years.ToString();
}
public string GetCallbackResult()
{
return result;
}
這裏是JavaScript函數:
<script language="javascript" type="text/javascript">
function InitiateCallBack(value) {
CallServer(value, '');
}
// Called after the server side processing is done
function ReceiveServerData(arg, context) {
$("#MainContent_ASPxtxtAge_I").val(arg);
}
</script>
這裏只有單一的時間回撥的發生,但我怎麼能叫多次從多個按鈕?
我正在使用devexpress以及asp .net c#。 關於這個問題的任何建議?
如果我宣佈更多然後在客戶端的一個功能,每一個功能在後面的功能RaiseCallbackEvent碼打。 – asasasaa
對不起@asasasaa我不明白你的意思 –