定义 ASP.NET 服务器控件为处理回发事件而必须实现的方法。

下面的代码示例定义一个自定义按钮服务器控件,该控件可引起回发,使用 RaisePostBackEvent 方法捕获回发,并在服务器上引发 Click 事件。(摘自MSDN)
IPostBackEventHandler 接口Imports System
IPostBackEventHandler 接口Imports System.Web.UI
IPostBackEventHandler 接口Imports System.Collections
IPostBackEventHandler 接口Imports System.Collections.Specialized
IPostBackEventHandler 接口
IPostBackEventHandler 接口Namespace CustomControls
IPostBackEventHandler 接口    
IPostBackEventHandler 接口  Public Class MyButton
IPostBackEventHandler 接口        Inherits Control
IPostBackEventHandler 接口        Implements IPostBackEventHandler
IPostBackEventHandler 接口        
IPostBackEventHandler 接口        ' Define the Click event.
IPostBackEventHandler 接口        Public Event Click As EventHandler
IPostBackEventHandler 接口                
IPostBackEventHandler 接口        ' Invoke delegates registered with the Click event.
IPostBackEventHandler 接口        Protected Overridable Sub OnClick(e As EventArgs)            
IPostBackEventHandler 接口            RaiseEvent Click(Me, e)
IPostBackEventHandler 接口        End Sub
IPostBackEventHandler 接口                
IPostBackEventHandler 接口        ' Define the method of IPostBackEventHandler that raises change events.
IPostBackEventHandler 接口        Public Sub RaisePostBackEvent(eventArgument As String) _
IPostBackEventHandler 接口        Implements IPostBackEventHandler.RaisePostBackEvent
IPostBackEventHandler 接口        
IPostBackEventHandler 接口            OnClick(New EventArgs())
IPostBackEventHandler 接口        End Sub       
IPostBackEventHandler 接口               
IPostBackEventHandler 接口        Protected Overrides Sub Render(output As HtmlTextWriter)
IPostBackEventHandler 接口            output.Write("
<INPUT TYPE = submit name = " & Me.UniqueID & _
IPostBackEventHandler 接口                "
 Value = 'Click Me' />")
IPostBackEventHandler 接口        End Sub
IPostBackEventHandler 接口        
IPostBackEventHandler 接口    End Class
IPostBackEventHandler 接口End Namespace

keyword: IPostBackEventHandler ,RaisePostBackEvent,控件回发

相关文章: