using System;
using System.Web.UI;
using Tripal.Web.Biz.Common;
using System.Web.UI.WebControls;
namespace *****.Web.Biz.UI.Common
{
public delegate void CallBackEventHandler(object sender, CallBackArgs e);
public class CallBackArgs:EventArgs
{
public CallBackArgs(string commandName, string commandArgument)
{
_commandArgument = commandArgument;
_commandName = commandName;
}
private string _commandName;
public string CommandName
{
set{_commandName=value;}
get{return _commandName;}
}
private string _commandArgument;
public string CommandArgument
{
set{_commandArgument = value;}
get{return _commandArgument;}
}
}
/// <summary>
/// Call 的摘要说明。
/// </summary>
public class CallBackCustomerControl : Telerik.WebControls.RadCallback
{
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
this.Callback +=new CallbackEvent(CallBackCustomerControl_Callback);
}
private void CallBackCustomerControl_Callback(object sender, Telerik.WebControls.CallbackEventArgs args)
{
if( ProcessCallBack != null )
{
CallBackArgs e = new CallBackArgs( args.CallbackEvent, args.Args );
ProcessCallBack( sender, e );
}
}
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer);
writer.Write( "<script> function "+this.ClientID+"MakeCallback( commandName, commandArgument ) { MakeCallback('"+this.ClientID+"', commandName, commandArgument); } </script>");
}
//事件
public event CallBackEventHandler ProcessCallBack;
}
}
using System.Web.UI;
using Tripal.Web.Biz.Common;
using System.Web.UI.WebControls;
namespace *****.Web.Biz.UI.Common
{
public delegate void CallBackEventHandler(object sender, CallBackArgs e);
public class CallBackArgs:EventArgs
{
public CallBackArgs(string commandName, string commandArgument)
{
_commandArgument = commandArgument;
_commandName = commandName;
}
private string _commandName;
public string CommandName
{
set{_commandName=value;}
get{return _commandName;}
}
private string _commandArgument;
public string CommandArgument
{
set{_commandArgument = value;}
get{return _commandArgument;}
}
}
/// <summary>
/// Call 的摘要说明。
/// </summary>
public class CallBackCustomerControl : Telerik.WebControls.RadCallback
{
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
this.Callback +=new CallbackEvent(CallBackCustomerControl_Callback);
}
private void CallBackCustomerControl_Callback(object sender, Telerik.WebControls.CallbackEventArgs args)
{
if( ProcessCallBack != null )
{
CallBackArgs e = new CallBackArgs( args.CallbackEvent, args.Args );
ProcessCallBack( sender, e );
}
}
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer);
writer.Write( "<script> function "+this.ClientID+"MakeCallback( commandName, commandArgument ) { MakeCallback('"+this.ClientID+"', commandName, commandArgument); } </script>");
}
//事件
public event CallBackEventHandler ProcessCallBack;
}
}
本文介绍了一种基于ASP.NET的自定义回调控件实现方式,通过创建自定义的CallBackCustomerControl类继承自Telerik的RadCallback控件,并定义了自定义事件处理委托和参数传递方法,使得该控件能够在客户端触发事件后进行服务器端回调。
1737

被折叠的 条评论
为什么被折叠?



