peter

peter

  • NA
  • 320
  • 0

Reference ImageButton handler when UserControl loaded in page.

Feb 19 2022 4:59 PM

 Protected Sub dataList_ItemCreated(sender As Object, e As DataListItemEventArgs) Handles dataList.ItemCreated

 AddHandler imgSlideShow.Click, New ImageClickEventHandler(AddressOf imgSlideShow_Click)

End Sub

'This is Click event definition for SlideShow control.
    Public Event Click As SlideShowClick

    Public Delegate Sub SlideShowClick(ByVal sender As Object, ByVal e As SlideShowImageEventArgs)


    Protected Sub imgSlideShow_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
        RaiseEvent Click(Me, New SlideShowImageEventArgs(CType(sender, ImageButton), e.X, e.Y))
    End Sub

    
    'Before when declared in Page form
     <uc1:WebUserControl2 runat="server" id="WebUserControl2" OnClick="SlideShow1_Click" 
                  />

Now loaded in page

 Dim uc As ASP.WebUserControl2 = CType(Page.LoadControl(controlPath), ASP.WebUserControl2)

uc.SlideShowClick = "SlideShow1_Click"

   Public Sub SlideShow1_Click(ByVal sender As Object, ByVal e As SlideShowImageEventArgs)
 

Error message says this is a type and cannot be used in an expression.