62,074
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
namespace WebApp
{
public class UListBox : System.Web.UI.WebControls.ListBox, IPostBackEventHandler
{
private static readonly Object EventDbClick = new Object();
/// <summary>
/// 当由类实现时,用信号要求服务器控件对象通知 ASP.NET 应用程序该控件的状态已更改
/// </summary>
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
OnDbClick(EventArgs.Empty);
}
public event EventHandler DbClick
{
add
{
Events.AddHandler(EventDbClick, value);
}
remove
{
Events.RemoveHandler(EventDbClick, value);
}
}
/// <summary>
/// 引发 OnDbClick 事件。
/// </summary>
/// <param name="e">事件基类</param>
protected virtual void OnDbClick(EventArgs e)
{
EventHandler clickHandler = (EventHandler)Events[EventDbClick];
if (clickHandler != null)
{
System.Web.UI.WebControls.ListItem item = this.SelectedItem;
clickHandler((object)item, e);
}
}
/// <summary>
/// 重写控件的呈现
/// </summary>
/// <param name="output">输出流</param>
protected override void Render(HtmlTextWriter output)
{
this.Attributes.Add("ondblclick", this.Page.GetPostBackEventReference(this, ""));
base.Render(output);
}
}
}