Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
One of my project requirement is:

When i place the cursor on an imagebutton, it has to be highlighted.
(i.e border of the button has to be changed).
when i move out the cursor, it should be normal.

I have used the following code:
<td>    <asp:ImageButton ID="Img14" ImageUrl="IMG/16_print.gif" onmouseover = "highlight_Img14()" onmouseout = "removehightlight_Img14()"    runat = "server"  OnclientClick = "window.open('http://www.google.co.in','mywindow','location=0,status=0,resizable=yes,scrollbars=0,left=700,top=128,width=800px,height=900px');" />  </td>                                  

function highlight_Img14() {

        document.getElementById("Img14").style.border = "0.5px solid yellow";

    }
    function removehightlight_Img14() {

        document.getElementById("Img14").style.border = "0px solid yellow";
    }



It is working fine. Only problem is the image buttons next to it are moving towards right side. I have tried using padding = 0 , position = "fixed/absolute". But still the issue is not resolved.
Posted
Updated 16-May-13 3:51am
v3
Comments
Richard C Bishop 16-May-13 9:52am    
Have you tried using margin?
Member 10036131 16-May-13 9:57am    
I tried margin now and it did not work (imagebutton is not even highlighted when the cursor placed on it). thanks
code which i had written is working fine, only problem is image buttons next to it are moving right.
ZurdoDev 16-May-13 12:08pm    
You need to reply to the comment not add a new comment to your own question. That way the person who made the comment will be notified.

1 solution

Try setting the td element to a fixed Width. For example if your button is 140 pixels, set your td to 150 pixels. This should leave enough room for the border to be drawn.
 
Share this answer
 
v2
Comments
Member 10036131 17-May-13 2:41am    
I have tried setting the td width to little greater than button width, still the imagebutton is moving
Yuriy Loginov 17-May-13 8:11am    
have you tried setting the border on the td element instead of the Image Button?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900