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. Need help with ImageButton

Need help with ImageButton

Scheduled Pinned Locked Moved ASP.NET
questionhelpdiscussion
11 Posts 3 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.
  • A Offline
    A Offline
    AprNgp
    wrote on last edited by
    #1

    I am using asp:ImageButton control . I want to associate 3 images with it, for MouseOve, MouseOut and MouseClick events. How can i achieve this ? Right now, i m using

    Apurv A man is but the product of his thoughts. What he thinks, he becomes. .......Mahatma Gandhi Be the change you want to see in the world. .......Mahatma Gandhi

    C J 2 Replies Last reply
    0
    • A AprNgp

      I am using asp:ImageButton control . I want to associate 3 images with it, for MouseOve, MouseOut and MouseClick events. How can i achieve this ? Right now, i m using

      Apurv A man is but the product of his thoughts. What he thinks, he becomes. .......Mahatma Gandhi Be the change you want to see in the world. .......Mahatma Gandhi

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You will need to write javascript to do this, I don't believe the control supports it directly.

      Christian Graus Driven to the arms of OSX by Vista.

      1 Reply Last reply
      0
      • A AprNgp

        I am using asp:ImageButton control . I want to associate 3 images with it, for MouseOve, MouseOut and MouseClick events. How can i achieve this ? Right now, i m using

        Apurv A man is but the product of his thoughts. What he thinks, he becomes. .......Mahatma Gandhi Be the change you want to see in the world. .......Mahatma Gandhi

        J Offline
        J Offline
        Jorgen Andersson
        wrote on last edited by
        #3

        In Page_Load Add

        btnAYes.Attributes.Add("onmouseover", "src = 'images/pic1.png'")
        btnAYes.Attributes.Add("onmouseout", "src = 'images/pic2.png'")
        btnAYes.Attributes.Add("onmouseclick", "src = 'images/pic3.png'")

        C A 2 Replies Last reply
        0
        • J Jorgen Andersson

          In Page_Load Add

          btnAYes.Attributes.Add("onmouseover", "src = 'images/pic1.png'")
          btnAYes.Attributes.Add("onmouseout", "src = 'images/pic2.png'")
          btnAYes.Attributes.Add("onmouseclick", "src = 'images/pic3.png'")

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          why not just put it in the aspx ?

          Christian Graus Driven to the arms of OSX by Vista.

          J 1 Reply Last reply
          0
          • C Christian Graus

            why not just put it in the aspx ?

            Christian Graus Driven to the arms of OSX by Vista.

            J Offline
            J Offline
            Jorgen Andersson
            wrote on last edited by
            #5

            Like this you mean:

            <img name="img1" src="/images/whatever1.gif" onmouseover="document.images['img1'].src = '/images/whatever2.gif';" onmouseout="document.images['img1'].src = '/images/whatever1.gif';">

            I never thought about that until you asked why not. :doh: The other method has always done what I needed.

            C 1 Reply Last reply
            0
            • J Jorgen Andersson

              Like this you mean:

              <img name="img1" src="/images/whatever1.gif" onmouseover="document.images['img1'].src = '/images/whatever2.gif';" onmouseout="document.images['img1'].src = '/images/whatever1.gif';">

              I never thought about that until you asked why not. :doh: The other method has always done what I needed.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Yeah, both ways work, I guess the real question is, when you're maintaining the code, which is the place you're most likely to expect to see this set ? I'd expect that depends on the coder, you're used to looking in one place, I am used to looking in the other.

              Christian Graus Driven to the arms of OSX by Vista.

              J 2 Replies Last reply
              0
              • C Christian Graus

                Yeah, both ways work, I guess the real question is, when you're maintaining the code, which is the place you're most likely to expect to see this set ? I'd expect that depends on the coder, you're used to looking in one place, I am used to looking in the other.

                Christian Graus Driven to the arms of OSX by Vista.

                J Offline
                J Offline
                Jorgen Andersson
                wrote on last edited by
                #7

                For maintaining the code, it's definitely better in the aspx. But I just remember why I used the other method, i didn't get it to work in the aspx. And neither did I now. But I'll have a look into that tomorrow. It's way to late for my brain now.

                1 Reply Last reply
                0
                • C Christian Graus

                  Yeah, both ways work, I guess the real question is, when you're maintaining the code, which is the place you're most likely to expect to see this set ? I'd expect that depends on the coder, you're used to looking in one place, I am used to looking in the other.

                  Christian Graus Driven to the arms of OSX by Vista.

                  J Offline
                  J Offline
                  Jorgen Andersson
                  wrote on last edited by
                  #8

                  Well, I don't get it to work in the aspx. Asp:ImageButton doesn't support OnMouseOver or OnMouseOut natively. But if you know how to do it in the aspx I'm definitely interested.

                  1 Reply Last reply
                  0
                  • J Jorgen Andersson

                    In Page_Load Add

                    btnAYes.Attributes.Add("onmouseover", "src = 'images/pic1.png'")
                    btnAYes.Attributes.Add("onmouseout", "src = 'images/pic2.png'")
                    btnAYes.Attributes.Add("onmouseclick", "src = 'images/pic3.png'")

                    A Offline
                    A Offline
                    AprNgp
                    wrote on last edited by
                    #9

                    Thanks ..... it working ... thank you very much ... :)

                    Apurv A man is but the product of his thoughts. What he thinks, he becomes. .......Mahatma Gandhi Be the change you want to see in the world. .......Mahatma Gandhi

                    J 1 Reply Last reply
                    0
                    • A AprNgp

                      Thanks ..... it working ... thank you very much ... :)

                      Apurv A man is but the product of his thoughts. What he thinks, he becomes. .......Mahatma Gandhi Be the change you want to see in the world. .......Mahatma Gandhi

                      J Offline
                      J Offline
                      Jorgen Andersson
                      wrote on last edited by
                      #10

                      You're welcome

                      A 1 Reply Last reply
                      0
                      • J Jorgen Andersson

                        You're welcome

                        A Offline
                        A Offline
                        AprNgp
                        wrote on last edited by
                        #11

                        but if it wroks form code-behind, y don't it work from aspx ?

                        Apurv A man is but the product of his thoughts. What he thinks, he becomes. .......Mahatma Gandhi Be the change you want to see in the world. .......Mahatma Gandhi

                        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