Solved

Image change in asp.NET/vb.NET

Posted on 2011-09-25
7
183 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
  • 4
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now