Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm having trouble with this onmouseover, it seems that my VS 2008 can't recognized it. There's no such event there. Please help.
Posted

XML
You will not get  onmouseover in intellisense of VS 2008 but if you will add it manually it will work. I just tested below code.

<asp:Button ID="Button1" onmouseover="alert(1)" runat="server" Text="Button" />
 
Share this answer
 
Comments
Chris N.P. 20-May-13 3:28am    
Thanks now it's clear.
I also have one concern and I believe you could help me.
I do have a page in one of my web application that recursively get all the folders of the server's D drive and inside each folder it contains files and subfolders. Now what I want to do is to apply an image preview when I hover the mouse on it.
Please help me.
check this sample below:
HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="onmouseover.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Onmouseover</title>
    <script type="text/javascript">
        function bigImg(x) {
            x.style.height = "270px";
            x.style.width = "500px";
        }

        function normalImg(x) {
            x.style.height = "135px";
            x.style.width = "250px";

        }

</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/code.gif" onmouseover="bigImg(this)" onmouseout="normalImg(this)" border="0" />

<p>The function bigImg() is triggered when the user moves the mouse pointer over the image.</p>
<p>The function normalImg() is triggered when the mouse pointer is moved out of the image.</p>


    </div>
    </form>
</body>
</html>


and for your thumbnail preview of images-

Display Full Size Image on Mouse Over Thumbnail in ASP.NET[^]


for link button:
HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="onmouseover.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Onmouseover</title>
    <script type="text/javascript">
        function displayResult() {
            document.getElementById("p1").style.fontSize = "xx-large";
        }
        function displayResult1() {
            document.getElementById("p1").style.fontSize = "x-small";
        }


</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:LinkButton ID="p1" runat="server" onmouseover="displayResult()"
            onmouseout="displayResult1()" onclick="p1_Click"  >sample text</asp:LinkButton>





    </div>
    </form>
</body>
</html>



C#
protected void p1_Click(object sender, EventArgs e)
       {
          Response.Redirect("~/code.gif"); // code.gif is image file included in my project. // you  can also use modalpopup/facybox to display the images from thumbnails.
       }
 
Share this answer
 
v3
Comments
Chris N.P. 20-May-13 4:04am    
Thank you this is helpful.
However I still have a bit of a concern.
Let's say I want to use ASP:LinkButton instead of ASP:Image. I'm having trouble with the property that i'm going to use. I don't know the right property to use and how to set the value of the property to the url/location of the image that is located on the server's D: drive. Of course the value will vary from one file location to another. I know we are almost there but I need further advice and help from you guys. Thank you.
Abhishek Pant 20-May-13 5:24am    
see updated answer above.
Create a div, inside that div create img tag keep div display none initially. OnMouserOver set the coordinates of this div based on element which fired the onmouseover event and now assign img src path to the image you want to preview and remove display none of div. OnMouseOut set div display to none back.

Please let me know if you need further assistance.
 
Share this answer
 
Comments
Chris N.P. 20-May-13 4:07am    
Thank you. Do you have a sample code for this? I believe this would help me.
Chris N.P. 20-May-13 4:25am    
Let's assume that there are 3 folders inside the server's D drive.
d:/folder1
d:/folder2
d:/folder3

Inside each folders there are 2 image files.
d:/folder1/img1.1.jpg
d:/folder1/img1.2.jpg
d:/folder2/img2.1.jpg
d:/folder2/img2.2.jpg
d:/folder3/img3.1.jpg
d:/folder3/img3.3.jpg
Now a particular page will going to get all the folders on the D drive and display it using a gridview.

What i want to do is to hover the mouse on one of the image files so that it will show me an image tooltip to preview the particular image.

However I don't know how ASP:LinkButton will be able to capture the location of the particular image selected. Of course I can't do this "~/img1.1.jpg" for example since it's in the D drive.

Using DIV that you mentioned is like unfamiliar territory for me but it's an enteresting approach. Please provide me a code. I will greatly appreciate your help.
Here I believe you have two challenges
1. show any local image on browser which not inside your web application (i.e D drive)
2. Javascript logic to show image preview on mouseover

Solution for the First is given below and for second I don’t have any code right now

There is no straight way to show any local image on browser which is not inside your web application as you cannot map path to that image from your web page.

Follow below steps

->Create a .aspx page Say ViewImage.aspx
->You need to pass path of image as QueryString which want to show

C#
protected void Page_Load(object sender, EventArgs e)
      {
          string filePath = Request.QueryString["filePath"];
          Response.Clear();
          Response.ContentType = "image/jpeg";
          Response.BinaryWrite(File.ReadAllBytes(filePath));
          Response.End();
      }
 
Share this answer
 
v2
Comments
Chris N.P. 20-May-13 21:05pm    
Alright I got the first one. Thank you.
I'm going to work on the JavaScript side. However I'm still looking forward to your javascript version for this scenario.
I will regularly check this post. Thank you.

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