ListCommandEventHandler 委托

定义

警告

此 API 现已过时。

表示将用来处理 ItemCommandList 事件的方法。Represents the method that will handle the ItemCommand event of a List. 若要了解如何开发 ASP.NET 移动应用,请参阅 ASP.NET 移动应用和网站For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

public delegate void ListCommandEventHandler(System::Object ^ sender, ListCommandEventArgs ^ e);
[System.Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see https://go.microsoft.com/fwlink/?LinkId=157231.")]
public delegate void ListCommandEventHandler(object sender, ListCommandEventArgs e);
type ListCommandEventHandler = delegate of obj * ListCommandEventArgs -> unit
Public Delegate Sub ListCommandEventHandler(sender As Object, e As ListCommandEventArgs)

参数

sender
Object

事件的源,即 List 控件。The source of the event, a List control.

e
ListCommandEventArgs

包含事件数据的 ListCommandEventArgs 对象。A ListCommandEventArgs object that contains the event data.

继承
ListCommandEventHandler
属性

注解

List 控件创建 ListCommandEventHandler 委托时,需要标识将处理该事件的方法。When you create a ListCommandEventHandler delegate for a List control, you identify the method that will handle the event. 生成项事件时,ListControl 通知处理程序。The ListControl notifies the handler when an item event is generated. 若要将事件与事件处理程序关联,请将该委托的一个实例添加到事件中。To associate the event with your event handler, add an instance of the delegate to the event. 除非移除了该委托,否则每当发生该事件时都会调用事件处理程序。Unless you remove the delegate, the event handler is called whenever the event occurs.

对于默认呈现,控件提供一个用户界面,用户可通过该 UI 单击各个列表项。For default rendering, the control provides a UI that allows the user to click individual list items. 在回发时,控件调用 OnItemCommand 事件处理程序,其中包含指向源项的参数。On postback, the control calls the OnItemCommand event handler, with an argument pointing to the source item. CommandName 属性的值为 nullThe value of the CommandName property is null.

使用模板进行呈现时,ASP.NET 的事件冒泡机制将调用 OnItemCommand 方法。When rendering with a template, the event bubbling mechanism of ASP.NET calls the OnItemCommand method. 向事件处理程序传递一个参数,该参数指向源项,并传递给生成事件的控件的 CommandName 属性。The event handler is passed a parameter, pointing to the source item, and to the CommandName property of the control that generated the event. 这允许您呈现具有多个关联交互的单个列表项。This allows you to render a single list item with multiple associated interactions.

若要将项呈现为超链接,可以将 ItemsAsLinks 属性设置为 trueTo render an item as a hyperlink, you can set the ItemsAsLinks property to true. Text 属性的值用于显示,并且在选中时,Value 属性的内容将用作目标链接地址。The value of the Text property is used for display, and the contents of the Value property are used as the target link address when selected.

备注

不会为这些链接生成命令事件。Command events will not be generated for these links.

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于

另请参阅