We help IT Professionals succeed at work.

.net repeater chrome onmouseover

Mark_SDLLC
Mark_SDLLC asked
on
I have a repeater that displays images.  I want the image to get larger when I mouseover.  I used hoverbox to make this happen.  It works correctly outside the repeater but when I use the .net repeater hoverbox does not work in chrome.  It does work in IE.

http://pm.sdweb.info/Projects.aspx?Project_ID=1

 
<asp:Repeater ID="rptImages" runat="server">
  <ItemTemplate>
    <ul class="hoverbox">
      <li>
        <a href="ImageViewer.aspx?Image_ID=<%# Eval("IMAGE_ID") %>&PROJECT_ID=<%# Eval("PROJECT_ID") %>" onmouseover="ddrivetip('<%# Container.DataItem("Title") %>')" onmouseout="hideddrivetip()" class="jTip2"><img src="<%# Eval("IMAGE_SOURCE") %>" alt="Project Photo" /><img src="<%# Eval("IMAGE_SOURCE") %>" class="preview" alt="Project Photo" /></a>
       </li>
     </ul>
   </ItemTemplate>
</asp:Repeater>

Open in new window



/* =Hoverbox Code
----------------------------------------------------------------------*/

.hoverbox
{
	cursor: default;
	list-style: none;
}

.hoverbox a
{
	cursor: default;
}

.hoverbox a .preview
{
	display: none;
}

.hoverbox a:hover .preview
{
	display: block;
	position: absolute;
	top: -33px;
	left: -45px;
	z-index: 1;
}

.hoverbox img
{
	background: #fff;
	border-color: #aaa #ccc #ddd #bbb;
	border-style: solid;
	border-width: 1px;
	color: inherit;
	padding: 2px;
	vertical-align: top;
	width: 200px;
	height: 150px;
}

.hoverbox li
{
	background: #eee;
	border-color: #ddd #bbb #aaa #ccc;
	border-style: solid;
	border-width: 1px;
	color: inherit;
	display: inline;
	float: left;
	margin: 3px;
	padding: 5px;
	position: relative;
}

.hoverbox .preview
{
	border-color: #000;
	width: 400px;
	height: 300px;
}



/* =Internet Explorer Fixes
----------------------------------------------------------------------*/
.hoverbox a
{
	position: relative;
}

.hoverbox a:hover
{
	display: block;
	font-size: 100%;
	z-index: 1;
}

.hoverbox a:hover .preview
{
	top: -38px;
	left: -50px;
}

.hoverbox li
{
	position: static;
}

Open in new window

Comment
Watch Question

GlobaLevelProgrammer

Commented:
Im thinking that you need a JS to check the browser and handle any differences...
Full Stack .NET Developer
Commented:
Hello, the problem in Chrome is because these lines in your css file (http://pm.sdweb.info/styles/style.css):
/* =Internet Explorer Fixes
----------------------------------------------------------------------*/
.hoverbox a
{
	position: relative;
}

.hoverbox a:hover
{
	display: block;
	font-size: 100%;
	z-index: 1;
}

.hoverbox a:hover .preview
{
	top: -38px;
	left: -50px;
}

.hoverbox li
{
	position: static;
}

Open in new window


You can make it work in Chrome if you do this:
1. Move these lines from your style.css file to a new css file, named ie_style.css in the same location of style.css:
/* =Internet Explorer Fixes
----------------------------------------------------------------------*/
.hoverbox a
{
	position: relative;
}

.hoverbox a:hover
{
	display: block;
	font-size: 100%;
	z-index: 1;
}

.hoverbox a:hover .preview
{
	top: -38px;
	left: -50px;
}

.hoverbox li
{
	position: static;
}

Open in new window


2. In your page http://pm.sdweb.info/Projects.aspx, add these lines under your link to your css file:
    <!--[if IE]>
    <link href="styles/ie_style.css" rel="stylesheet" type="text/css" />
    <![endif]-->

Open in new window


So your page head element must be like:
<head>
    <link href="styles/style.css" rel="stylesheet" type="text/css" />
    <!--[if IE]>
    <link href="styles/ie_style.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <script type="text/javascript" src="js/jtip.js"></script>
    <title></title>
</head>

Open in new window


After that change, your page works well on IE7-9 (I have not tested on a lower version), Firefox and Chrome.

Author

Commented:
Thank You
Carlos VillegasFull Stack .NET Developer

Commented:
Glad to have been of help :)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.