locked
How to use a handles name to alter the code in its event RRS feed

  • Question

  • User-858993849 posted

    I have a subroutine and am wanting to use multiple handles to run it, altering the code in the subroutine based on a number in the handles name.  For example, I have 8 thumbnails and when they are clicked, I change the image url of an enlarged image to the imageurl of the thumbnail.  My thumbnails are named thumbnail1, thumbnail2, etc.  My subroutine looks like this.  Protected Sub ThumbNail_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ThumbNail1.Click, ThumbNail2.Click

    ImageLargeStatic.ImageUrl = Thumbnail?.ImageUrl

    End If

    LoadThumbNails()

    End Sub

     I want to determine which handle was used and then pull the number (1 or 2 in this case) out to be able to put it in the ? of the code above.

    Thursday, December 4, 2008 8:58 AM

Answers

  • User-653327211 posted

    try converting your code to this:

    Protected Sub ThumbNail_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ThumbNail1.Click, ThumbNail2.Click

    ImageLargeStatic.ImageUrl = Sender.ImageUrl

    End If

    LoadThumbNails()

    End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 4, 2008 9:39 AM

All replies

  • User-653327211 posted

    try converting your code to this:

    Protected Sub ThumbNail_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ThumbNail1.Click, ThumbNail2.Click

    ImageLargeStatic.ImageUrl = Sender.ImageUrl

    End If

    LoadThumbNails()

    End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 4, 2008 9:39 AM
  • User-858993849 posted

    Worked perfectly. 

    Thursday, December 4, 2008 11:45 AM