Export (0) Print
Expand All

Repeater.OnBubbleEvent Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Raises the ItemCommand event if the EventArgs parameter is an instance of RepeaterCommandEventArgs.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

'Declaration
Protected Overrides Function OnBubbleEvent ( _
	sender As Object, _
	e As EventArgs _
) As Boolean

Parameters

sender
Type: System.Object

The source of the event.

e
Type: System.EventArgs

An EventArgs object that contains the event data.

Return Value

Type: System.Boolean
true if the ItemCommand was raised, otherwise false.

The following code example demonstrates how to override the OnDataBinding method in a custom server control so that if the event argument is a command type, the Repeater control always calls the OnItemCommand and bubbles up the event, or returns false and cancels the event.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Custom Repeater - OnBubbleEvent - VB.NET Example</title>
        <script language="VB" runat="server">
            Sub Page_Load(Sender As Object, e As EventArgs)
                If Not IsPostBack Then
                    Dim values As New ArrayList()

                    values.Add(New PositionData("Microsoft", "Msft"))
                    values.Add(New PositionData("Intel", "Intc"))
                    values.Add(New PositionData("Dell", "Dell"))

                    Repeater1.DataSource = values
                    Repeater1.DataBind()
                End If
            End Sub

            Public Class PositionData

                Private myName As String
                Private myTicker As String        

                Public Sub New(newName As String, newTicker As String)
                    Me.myName = newName
                    Me.myTicker = newTicker
                End Sub        

                Public ReadOnly Property Name() As String
                    Get
                        Return myName
                    End Get
                End Property        

                Public ReadOnly Property Ticker() As String
                    Get
                        Return myTicker
                    End Get
                End Property
            End Class
        </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom Repeater - OnBubbleEvent - VB.NET Example</h3>

            <aspSample:CustomRepeaterOnBubbleEvent id="Repeater1" runat="server" >
                    <HeaderTemplate>
                        <table border="1" cellpadding="4" cellspacing="0">
                            <tr>
                                <th>Company</th>
                                <th>Symbol</th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                            <td> <%# DataBinder.Eval(Container.DataItem, "Name") %></td>
                            <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %></td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </aspSample:CustomRepeaterOnBubbleEvent>
        </form>
    </body>
</html>
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomRepeaterOnBubbleEvent
        Inherits System.Web.UI.WebControls.Repeater

        Protected Overrides Function OnBubbleEvent(ByVal [source] As Object, ByVal args As System.EventArgs) As Boolean 

            ' If the EventArgs are of type RepeaterCommadnEventArgs, 
            ' then call the OnItemCommand event handler and return true (bubble up the event) 
            ' else return false (don't bubble up the event). 
            Dim isHandled As Boolean = False 
            If TypeOf args Is System.Web.UI.WebControls.RepeaterCommandEventArgs Then 
                Me.OnItemCommand(CType(args, System.Web.UI.WebControls.RepeaterCommandEventArgs))
                isHandled = True 
            End If 
            Return isHandled
        End Function 
    End Class 
End Namespace

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft