?
Solved

Image change in asp.NET/vb.NET

Posted on 2011-09-25
7
Medium Priority
?
190 Views
Last Modified: 2012-05-12
I want to write a script for image changing in vb.NET/Asp.NEt.
Two images should be changing one after another after every 15  seconds or so.

Urgently required
0
Comment
Question by:Ammar Iqbal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36596002
your first image :
<asp:Image ID="Image1" runat="server" src="http://img39.imageshack.us/img39/2684/onlyinmexico69970146999.jpg" />

Open in new window

put the following in head section :
<script language="javascript" type="text/javascript">
    var slides = new Array(3);

    slides[0] = "http://img39.imageshack.us/img39/2684/onlyinmexico69970146999.jpg";
    slides[1] = "http://t0.gstatic.com/images?q=tbn:ANd9GcTitMd9yRepodcddFlBWdyj9NnmJeMxHTkECm7AuD7-25MVDJmeSFk_-ulHPA";
    slides[2] = "http://1.bp.blogspot.com/__gXsZ7-eRVw/SaXDuNBJK9I/AAAAAAAAS4g/fwXCAwq2bwY/s320/1711275404.jpg";

    var counter = 0;

    function imageChange() {
        counter++;
        if (counter == slides.length)
            counter = 0;
        document.getElementById("<%= Image1.ClientID %>").src = slides[counter];
    }

    setInterval(function () { imageChange() }, 15 * 1000);

</script>

Open in new window

Test page :
<%@ Page Title="Page d'accueil" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script language="javascript" type="text/javascript">
    var slides = new Array(3);

    slides[0] = "http://img39.imageshack.us/img39/2684/onlyinmexico69970146999.jpg";
    slides[1] = "http://t0.gstatic.com/images?q=tbn:ANd9GcTitMd9yRepodcddFlBWdyj9NnmJeMxHTkECm7AuD7-25MVDJmeSFk_-ulHPA";
    slides[2] = "http://1.bp.blogspot.com/__gXsZ7-eRVw/SaXDuNBJK9I/AAAAAAAAS4g/fwXCAwq2bwY/s320/1711275404.jpg";

    var counter = 0;

    function imageChange() {
        counter++;
        if (counter == slides.length)
            counter = 0;
        document.getElementById("<%= Image1.ClientID %>").src = slides[counter];
    }

    setInterval(function () { imageChange() }, 15 * 1000);

</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Image ID="Image1" runat="server" src="http://img39.imageshack.us/img39/2684/onlyinmexico69970146999.jpg" />
</asp:Content>

Open in new window

0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 36596035
<asp:Image ID="Image1"  runat="server" Width="805px" Height="370px"  ImageUrl="~/Web_Public/Portal/Deloitte/Images/Morgenfuglene_banner_01.jpg" />


I am not getting the second image , i stead I get only cross  in the iamge section. I have palced thsi script in "Content 1 " section
               
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36596049
if you have cross image it's because your image path is wrong of course

did you try the code without any modification? it's a good start and it work fine
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 36596135
i have tried but iam not getting iamge 1 back. i want that two image should swap eanch continuously at a certain time intyerval.

like this img1,img2,img1,img2.......
0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 36596169
thanx, its working.. how to increase the time interval
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36596173
If you can't see image1 you probably don't haver internet connexion or you change the path of the image...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36596183
SetInterval
Yiu ask for 15s
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question