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我不明白你的意思 –