Solved

Image change in asp.NET/vb.NET

Posted on 2011-09-25
7
186 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

17 Experts available now in Live!

Get 1:1 Help Now