0

I have problem with bubbleup event from my dynamic loaded ascx control (katalogbooklist.ascx) to it´s parent control (ViewAJBarnboksKatalog.ascx)
i need to fire/run sub uppdateraAndraModuler in the parent control when the event addMultiVotes_command fires in the chiled control.
is there any one who knows or have an idea on how to do this?

/ Andreas

(the code lives in a dotnetnuke cms modules, if that's any help)

Partial Class ViewAJBarnboksKatalog  '<--------Partial codebehind file for ViewAJBarnboksKatalog.ascx
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
         .. code for adding for loading katalogbooklist.ascx dynamic...
         Me.Controls.Add(..code.. add katalogbooklist.ascx ..) '
    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim t As Execkoden = New Execkoden()
        AddHandler t.onAjeventtest, AddressOf Uppdateramod          
    End Sub

    Public Sub Uppdateramod(sender As Object, e As ajeventArgs)
        uppdateraAndraModuler()
    End Sub

    Public Sub uppdateraAndraModuler()
           '..do some code
    End Sub
End Class     

Partial Class katalogenBookList  '<--------Partial codebehind file for katalogbooklist.ascx
    Protected Sub addMultiVotes_command(ByVal sender As Object, ByVal e As System.EventArgs)
      '..more code...
      Dim te As New Execkoden ' <----- i want to use the constructor to raise the event in class Execkoden can´t raiseevent directly it wont´t fire
       '... more code...
    End sub
End Class


Public Class ajeventArgs : Inherits EventArgs        
    Public Sub New()
    End Sub
End Class

Public Delegate Sub Uppdatera(sender As Object, e As ajeventArgs)

Public Class Execkoden
    Public Event onAjeventtest As Uppdatera
    Public Sub New()
        RaiseEvent onAjeventtest(Me, New ajeventArgs)
    End Sub
End Class
bdukes
  • 152,002
  • 23
  • 148
  • 175
theonealf
  • 89
  • 1
  • 11

2 Answers2

1

Create an event handler in the child control, like this:

public event EventHandler DeleteButtonClick;

When a button is clicked in the child control, do this:

protected void DeleteClick(object sender, EventArgs e)
{
    if (this.DeleteButtonClick != null)
        this.DeleteButtonClick(sender, e);
} 

And in your parent control, in the markup:

<UC:SomeUserControl ID="UserControl1" runat="server" OnDeleteButtonClick="UserControl1_DeleteClick" ...>

And in the code behind of the parent control:

protected void UserControl1_DeleteClick(object sender, EventArgs e)
{
    //do something
}
James Johnson
  • 45,496
  • 8
  • 73
  • 110
0

I would suggest using the IMC or Inter Module Communication feature that's built in to DotNetNuke.

Will Strohl
  • 1,646
  • 2
  • 15
  • 32