Qi Zai ~~ ~~
只为成功找方法,不为失败找借口!
定义 ASP.NET 服务器控件为处理回发事件而必须实现的方法。

下面的代码示例定义一个自定义按钮服务器控件,该控件可引起回发,使用 RaisePostBackEvent 方法捕获回发,并在服务器上引发 Click 事件。(摘自MSDN)
Imports System
Imports System.Web.UI
Imports System.Collections
Imports System.Collections.Specialized

Namespace CustomControls
    
  Public Class MyButton
        Inherits Control
        Implements IPostBackEventHandler
        
        ' Define the Click event.
        Public Event Click As EventHandler
                
        ' Invoke delegates registered with the Click event.
        Protected Overridable Sub OnClick(e As EventArgs)            
            RaiseEvent Click(Me, e)
        End Sub
                
        ' Define the method of IPostBackEventHandler that raises change events.
        Public Sub RaisePostBackEvent(eventArgument As String) _
        Implements IPostBackEventHandler.RaisePostBackEvent
        
            OnClick(New EventArgs())
        End Sub       
               
        Protected Overrides Sub Render(output As HtmlTextWriter)
            output.Write("
<INPUT TYPE = submit name = " & Me.UniqueID & _
                "
 Value = 'Click Me' />")
        End Sub
        
    End Class
End Namespace

keyword: IPostBackEventHandler ,RaisePostBackEvent,控件回发
posted on 2007-08-21 21:50  Blue Sky  阅读(344)  评论(0编辑  收藏  举报