Handling postback events in a server control (VB) : PostBack « Custom Controls « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » Custom Controls » PostBack 
14.11.4.Handling postback events in a server control (VB)
Imports System.ComponentModel
Imports System.Web.UI

<DefaultProperty("Text")> _
<ToolboxData("<{0}:WebCustomControl3 runat=server></{0}:WebCustomControl3>")> _
Public Class WebCustomControl3
    Inherits System.Web.UI.WebControls.WebControl
    Implements IPostBackEventHandler

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
        Dim As New PostBackOptions(Me)

        output.AddAttribute(HtmlTextWriterAttribute.Onclick, _
            Page.ClientScript.GetPostBackEventReference(p))

        output.AddAttribute(HtmlTextWriterAttribute.Value, "My Button")
        output.AddAttribute(HtmlTextWriterAttribute.Id, Me.ClientID)
        output.AddAttribute(HtmlTextWriterAttribute.Name, Me.ClientID)
        output.RenderBeginTag(HtmlTextWriterTag.Button)
        output.RenderEndTag()
    End Sub

    Public Event Click()
    Public Sub OnClick(ByVal args As EventArgs)
        RaiseEvent Click()
    End Sub

    Public Sub RaisePostBackEvent(ByVal eventArgument As StringImplements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
        OnClick(EventArgs.Empty)
    End Sub

End Class
14.11.PostBack
14.11.1.Adding PostBack capabilities to a server control (C#)
14.11.2.Adding PostBack capabilities to a server control (VB)
14.11.3.Handling postback events in a server control (C#)
14.11.4.Handling postback events in a server control (VB)
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.