Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<asp:DataList ID="DataList6" runat="server" RepeatDirection="Vertical">
<itemtemplate>

<asp:Image ID="Image1" runat="server"
Height="62px" Width="82px" ImageUrl='<%# Bind("main_image") %>'/>





<asp:Image ID="full image" runat="server" Height="450px" Width="350px" ImageUrl="a.jpg"/>






Here , i would to convert 'full image' imageurl to 'image1' imageurl on 'image1' mouseover event, please provide me with useful code.
Posted

i suggest you to use Jquery

changing image on mouseover
 
Share this answer
 
Comments
gagan13 17-Apr-14 9:13am    
i am new to jquery, can you provide me some example code, please?
Hi, you may either use JavaScript or JQuery. I have shown using JQuery. Place JQuery(.JS) file in the page when you have to use it. If you don't have .JS file than download from below code.

http://jquery.com/download/[^]

Place all below code within script tag.
First take the path of the image, such as below.

JavaScript
var Imagesrc = $('#Image1').attr("src");


Now use that variable to assign the source of the another image, as shown below.
JavaScript
$('#Image1').mouseover(function(){
$('#fullImage').attr("src",Imagesrc);
});


Hope this will help you.
 
Share this answer
 
v3
Comments
gagan13 17-Apr-14 12:11pm    
i am using 'image1' in datalist, so how would i get it's id in jquery you posted above?
DotNet WeblineIndia 18-Apr-14 4:04am    
There are multiple selectors in Jquery for achieving such scenario. Its also depends how you have placed them in the DataList as well, because while rendering to browser the id of all controls(reside within the DataList) get updated by the DataList control. The ID format is such as "DataListID_controllerID_RowsIndex".

In your case might it will be "#DatalistID_image1_0", but plz check it in the browser 'Developer tool' or 'Firebug'(by pressing F12 in the browser) and you may check in page sources also.

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