自定义事件

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;        
        
    }
}
posted @ 2006-07-11 09:19  烈马狂生  阅读(228)  评论(0编辑  收藏  举报