Solved event not firing through raiseevent

Posted on 2007-10-11
Last Modified: 2010-05-19
here's the scenario
    <asp:repeater ......

    <asp:linkbutton ... ></asp:linkbutton>

in the behind code for the user control, i have
public event evQueue
public sub linkbutton_click (....) handles
    raiseevent evQueue
end sub

the problem on the first page, is im not able to catch this
i tried doing this
Private Sub QueueAct() handles usercontrol.evQueue

End Sub

but it doesnt fire it.. my guess is because the user control is in a repeater, so something must have to be done in the databound, any ideas?
Question by:mocaiv
    LVL 27

    Expert Comment

    You need an EventHandler and to Raise it you do RaiseEvent(Me,e) where e is an EventArgs param

     Public Event Click As EventHandler
     Protected Overridable Sub OnClick(ByVal e As EventArgs)
         RaiseEvent Click(Me, e)
     End Sub

    Author Comment

    didnt work

    the code below doesnt work.. the testabc sub does not fire on raiseevent

    Main Page
      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not IsPostBack Then
                Dim dt As New DataTable
                Dim dc As New DataColumn("abc")
                Dim dr As DataRow
                dr = dt.NewRow
                dr(0) = "test"

                Repeater1.DataSource = dt
            End If
        End Sub
        Public Sub testabc(ByVal sender As Object, ByVal e As EventArgs)

        End Sub
        Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
            AddHandler CType(e.Item.Controls(1), WebUserControl2).evA, AddressOf testabc
        End Sub

    User Control:

       Public Event evA As EventHandler

        Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
            RaiseEvent evA(Nothing, Nothing)
        End Sub

    main web (html)

    <%@ Register TagPrefix="uc1" TagName="WebUserControl2" Src="WebUserControl2.ascx" %>
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="Test1.WebForm1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
                <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
                <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
                <meta name="vs_defaultClientScript" content="JavaScript">
                <meta name="vs_targetSchema" content="">
          <body MS_POSITIONING="GridLayout">
                <form id="Form1" method="post" runat="server">
                      <asp:Repeater id="Repeater1" runat="server">
                                  <uc1:WebUserControl2 id="WebUserControl21" runat="server"></uc1:WebUserControl2>

    user control html  
    <%@ Control Language="vb" AutoEventWireup="false" Codebehind="WebUserControl2.ascx.vb" Inherits="Test1.WebUserControl2" TargetSchema="" %>
    <asp:LinkButton id="LinkButton1" runat="server">LinkButton</asp:LinkButton>

    LVL 27

    Accepted Solution

    try it with AutoEventWireup="true"

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! How to Know You are Making a Difference at EE In August, 2013, one …
    New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
    This video teaches users how to migrate an existing Wordpress website to a new domain. provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now