Freigeben über


Repeater.OnBubbleEvent-Methode

Diese Methode unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.

Löst das ItemCommand-Ereignis aus, wenn der EventArgs-Parameter eine Instanz von RepeaterCommandEventArgs ist.

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

Syntax

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

returnValue = Me.OnBubbleEvent(sender, e)
protected override bool OnBubbleEvent (
    Object sender,
    EventArgs e
)
protected:
virtual bool OnBubbleEvent (
    Object^ sender, 
    EventArgs^ e
) override
protected boolean OnBubbleEvent (
    Object sender, 
    EventArgs e
)
protected override function OnBubbleEvent (
    sender : Object, 
    e : EventArgs
) : boolean

Parameter

  • sender
    Die Quelle des Ereignisses.
  • e
    Ein EventArgs-Objekt, das die Ereignisdaten enthält.

Rückgabewert

true, wenn der ItemCommand ausgelöst wurde, andernfalls false.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie die OnDataBinding-Methode in einem benutzerdefinierten Serversteuerelement überschrieben wird, damit für den Fall, dass das Ereignisargument ein Befehlstyp ist, das Repeater-Steuerelement immer OnItemCommand aufruft und ein Bubble erstellt oder false zurückgibt und das Ereignis abbricht.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
    <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>
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<HTML>
  <HEAD>
    <title>Custom Repeater - OnBubbleEvent - C# Example</title>
    <script language="C#" runat="server">
      void Page_Load(Object Sender, EventArgs e) 
      {
        if (!IsPostBack) 
        {
          ArrayList values = 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();
        }
      }

      public class PositionData 
      {
        private string name;
        private string ticker;

        public PositionData(string name, string ticker) 
        {
          this.name = name;
          this.ticker = ticker;
        }

        public string Name 
        {
          get 
          {
            return name;
          }
        }

        public string Ticker 
        {
          get 
          {
            return ticker;
          }
        }
      }
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom Repeater - OnBubbleEvent - C# 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>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<HTML>
  <HEAD>
    <title>Custom Repeater - OnBubbleEvent - VJ# Example</title>
    <script language="VJ#" runat="server">
        void Page_Load(Object Sender, EventArgs e) 
        {
            if (!get_IsPostBack()) {
                ArrayList values = new ArrayList();
                values.Add(new PositionData("Microsoft", "Msft"));
                values.Add(new PositionData("Intel", "Intc"));
                values.Add(new PositionData("Dell", "Dell"));
                Repeater1.set_DataSource(values);
                Repeater1.DataBind();
            }
        } //Page_Load

        public class PositionData 
        {
            private String name;
            private String ticker;

            public PositionData(String name, String ticker) 
            {
                this.name = name;
                this.ticker = ticker;
            } //PositionData

            /** @property 
             */
            public String get_Name()
            {
                return name;
            } //get_Name
    
            /** @property 
             */
            public String get_Ticker()
            {
                return ticker;
            } //get_Ticker
        } //PositionData 
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom Repeater - OnBubbleEvent - VJ# 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.get_DataItem(), "Name") %></td>
            <td> <%# DataBinder.Eval(Container.get_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
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
  [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class CustomRepeaterOnBubbleEvent : System.Web.UI.WebControls.Repeater
  {
    protected override bool OnBubbleEvent(object source, System.EventArgs args)
    {
      // If the EventArgs are of type RepeaterCommandEventArgs,
      // then call the OnItemCommand event handler and return true (bubble up the event)
      // else return false (don't bubble up the event).
      bool isHandled = false;
      if (args is System.Web.UI.WebControls.RepeaterCommandEventArgs) 
      {
        this.OnItemCommand((System.Web.UI.WebControls.RepeaterCommandEventArgs)args);
        isHandled = true;
      }
      return isHandled;
    }
  }
}
package Samples.AspNet.JSL.Controls; 

public class CustomRepeaterOnBubbleEvent
    extends System.Web.UI.WebControls.Repeater
{
    protected boolean OnBubbleEvent(Object source, System.EventArgs args)
    {
        // If the EventArgs are of type RepeaterCommandEventArgs,
        // then call the OnItemCommand event handler and return true 
        // (bubble up the event) 
        // else return false (don't bubble up the event).
        boolean isHandled = false;
        if (args instanceof System.Web.UI.WebControls.
            RepeaterCommandEventArgs) {
            this.OnItemCommand((System.Web.UI.WebControls.
                RepeaterCommandEventArgs)args);
            isHandled = true;
        }
        return isHandled;
    } //OnBubbleEvent
} //CustomRepeaterOnBubbleEvent

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Repeater-Klasse
Repeater-Member
System.Web.UI.WebControls-Namespace

Weitere Ressourcen

Repeater-Webserver-Steuerelement