• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Image change in asp.NET/vb.NET

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
Ammar Iqbal
Asked:
Ammar Iqbal
  • 4
  • 3
1 Solution
 
leakim971PluritechnicianCommented:
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
 
Ammar IqbalAuthor Commented:
<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
 
leakim971PluritechnicianCommented:
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
Technology Partners: 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!

 
Ammar IqbalAuthor Commented:
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
 
Ammar IqbalAuthor Commented:
thanx, its working.. how to increase the time interval
0
 
leakim971PluritechnicianCommented:
If you can't see image1 you probably don't haver internet connexion or you change the path of the image...
0
 
leakim971PluritechnicianCommented:
SetInterval
Yiu ask for 15s
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now