Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. imagebutton click

imagebutton click

Scheduled Pinned Locked Moved ASP.NET
sysadminquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    terjk
    wrote on last edited by
    #1

    Is this the right way to add an event handler? Dim img As New ImageButton AddHandler img.Click, AddressOf ImageClickHandler img.ImageUrl = Server.MapPath("Pics\aa.gif") Private Sub ImageClickHandler(ByVal sender As Object, ByVal e As ImageClickEventArgs) Response.Redirect("MyBookingNewBooking.aspx.aspx?BookingDate= " & dt & "ResourceName=" & name & "ResourceType=" & type) End Sub But this doesnt work... the page refresh instead of redirect to another page.

    M 1 Reply Last reply
    0
    • T terjk

      Is this the right way to add an event handler? Dim img As New ImageButton AddHandler img.Click, AddressOf ImageClickHandler img.ImageUrl = Server.MapPath("Pics\aa.gif") Private Sub ImageClickHandler(ByVal sender As Object, ByVal e As ImageClickEventArgs) Response.Redirect("MyBookingNewBooking.aspx.aspx?BookingDate= " & dt & "ResourceName=" & name & "ResourceType=" & type) End Sub But this doesnt work... the page refresh instead of redirect to another page.

      M Offline
      M Offline
      Michael Flanakin
      wrote on last edited by
      #2

      I think you need to declare your method as:

      Private Sub ImageClickHandler(...) Handles img.Click

      Michael Flanakin Web Log

      T 1 Reply Last reply
      0
      • M Michael Flanakin

        I think you need to declare your method as:

        Private Sub ImageClickHandler(...) Handles img.Click

        Michael Flanakin Web Log

        T Offline
        T Offline
        terjk
        wrote on last edited by
        #3

        Cannot work. I tried putting in the handles img.click. the imagebutton is create programmatically and it doesnt have the control name so i have error when i do that. Error msg: I guess it's because of the handles...etc.. but hwo can i solve this?

        M 1 Reply Last reply
        0
        • T terjk

          Cannot work. I tried putting in the handles img.click. the imagebutton is create programmatically and it doesnt have the control name so i have error when i do that. Error msg: I guess it's because of the handles...etc.. but hwo can i solve this?

          M Offline
          M Offline
          Michael Flanakin
          wrote on last edited by
          #4

          Is the ImageButton declared as part of the class? Or, part of a method? Michael Flanakin Web Log

          T 1 Reply Last reply
          0
          • M Michael Flanakin

            Is the ImageButton declared as part of the class? Or, part of a method? Michael Flanakin Web Log

            T Offline
            T Offline
            terjk
            wrote on last edited by
            #5

            Method So what should I do? Currently i just addhandler to my public sub createCalendar in the form behind codes.

            M 1 Reply Last reply
            0
            • T terjk

              Method So what should I do? Currently i just addhandler to my public sub createCalendar in the form behind codes.

              M Offline
              M Offline
              Michael Flanakin
              wrote on last edited by
              #6

              Do you have to have the ImageButton declared dynamically? If so, why? I would suggest you put the ImageButton declaration in the class and ASPX page. If you don't always need it displayed, make it hidden (Visible="false") by default. Michael Flanakin Web Log

              T 1 Reply Last reply
              0
              • M Michael Flanakin

                Do you have to have the ImageButton declared dynamically? If so, why? I would suggest you put the ImageButton declaration in the class and ASPX page. If you don't always need it displayed, make it hidden (Visible="false") by default. Michael Flanakin Web Log

                T Offline
                T Offline
                terjk
                wrote on last edited by
                #7

                I have to! This is because the number of rows of that tables is unpredictable. So i have to generate each row with the image button based on the number of records. No other way out?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups