Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everybody,
I need a javacript function for showing a div on the mouse over of an image button, which is an item of a datalist, so please help me for finding the solution.
Thanking you...
Posted
Updated 10-May-17 5:18am

You need to read this:
How to: Customize DataList Items at Run Time [^]

In your datalist ItemDataBound:
C#
protected void DataList1_ItemDataBound(object sender, 
        DataListItemEventArgs e)
{
   if(e.Item.ItemType == ListItemType.Item || 
          e.Item.ItemType == ListItemType.AlternatingItem)
   {
       // Use findControl to get the image. 
       // Use image.Attributes.Add("onmouseover", "alert('Hi!');");
    }
}
 
Share this answer
 
Comments
vpmanu 21-May-10 1:57am    
Thank you for your reply,
I need to perform the click of the image button when we mouse over of the image button, how to perform this?
Ratish jha 18-Jan-13 2:22am    
pls send full code for this
mohit.jain363@yahoo.com
Sandeep Mewara 18-Jan-13 5:50am    
Anything else? Money... Gold... Burger?

:)
Ratish jha 18-Jan-13 2:23am    
show div on mouseover in dtata'otem template-image tag
vpmanu wrote:
I need to perform the click of the image button when we mouse over of the image button, how to perform this?


Once you have appended the Javascript to MouseOver as described earlier, in the JS event you can call/trigger the imagebutton's click event!

Pass 'this' as one of the parameters to the JS to have direct access to it.
C#
// code behind use:
// imageBut.Attributes.Add("onmouseover", "OnMouseOverCustom(this);");

// Javascript
// function OnMouseOverCustom(myControl)
//{
//     myControl.Click();
//}
 
Share this answer
 
Hi

First make the div css visibility:hidden and a javascript function as below change according to u r requirement

function hideDiv(divID,visibility)
{
if(visibility == false)
{
var divelement = document.getElementByID(divID)
divelement.visibility = hidden;
}
else
{
var divelement = document.getElementByID(divID)
divelement.visibility = visible;
}
}

on mouse over just send visibility true and on mouse out visbility false
if u have to position the div use absalute and position according to u r current mouse pointer position
 
Share this answer
 
Comments
Sandeep Mewara 21-May-10 1:08am    
I guess he needs to know how to add a javascript function to image button placed inside a datalist.
vpmanu 21-May-10 1:54am    
Thank you for your reply, i know to write these type of function, my problem is how to get the datalist item in the javascript, for example, if i copy your function to the tag, and how to set the attributes to my datalist item

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