Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 25th, 2008, 10:15 PM   #1
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 369
Rep Power: 0 King is an unknown quantity at this point
Question Slide Show

I am doing a website in ASP.Net and I need to implement a slide show and I have a few questions.

I was able to implement one in JavaScript fairly easily, but I need to be able to load all the images from a folder without knowing how many images there will be and I do not think that is possible with JavaScript. If there is a way to be able to read/display all the images from a folder (without knowing all the files names) with JavaScript please let me know .

If the JavaScript way is not possible I will do it server-side. If I do it server-side is there a way to have it automatically switch the picture after X amount of time without an AJAX timer or anything fancy like that?

I may just end up using the AJAX slide show control. It is a fairly simple website and did not want to use too much server-side code or AJAX stuff. Thanks for any input on this.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Mar 26th, 2008, 6:01 AM   #2
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 290
Rep Power: 4 Ghost is on a distinguished road
Re: Slide Show

Please post java-script
__________________
People who click "images" that end with .exe shouldn't have computers.
Ghost is offline   Reply With Quote
Old Mar 26th, 2008, 6:32 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Re: Slide Show

I would use ASP.NET to tell the JavaScript what the file names are. Not sure about ASP, but this is how I'd do it in PHP:
php Syntax (Toggle Plain Text)
  1. <?php
  2. $imageDir = 'images/';
  3. $imagePaths = scandir($imageDir);
  4. echo 'var imagePaths = Array ("' . implode('", "', $imagePaths) . '")';
  5. ?>
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 26th, 2008, 3:31 PM   #4
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 290
Rep Power: 4 Ghost is on a distinguished road
Re: Slide Show

Here are a few places to check out.

http://www.asp.net/AJAX/AjaxControlT...SlideShow.aspx

http://aspnet.4guysfromrolla.com/articles/070704-1.aspx

http://www.codeproject.com/KB/ajax/ASPNETSlideShow.aspx
__________________
People who click "images" that end with .exe shouldn't have computers.
Ghost is offline   Reply With Quote
Old Mar 26th, 2008, 5:21 PM   #5
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 403
Rep Power: 3 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Re: Slide Show

Don't know if this will be of use to you, as I just happened over it and didn't really inspect it too closely:
http://www.wikicodia.com/wiki/JavaSc...ory_files_list
http://www.codeproject.com/KB/script..._in_files.aspx
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Mar 26th, 2008, 5:51 PM   #6
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 403
Rep Power: 3 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Re: Slide Show

Alright I tested the following code on my local Apache server:
<script type="text/javascript">
function httpGetText(aURL) {
  var req = new XMLHttpRequest();
  req.open('GET', aURL, false); 
  req.send(null);
  return req.responseText;
}
document.write(httpGetText('http://localhost/somedir/'));
</script>
I created a temporary directory called 'somedir' and it worked. However, if I added an index.htm file into the directory it just returned that file rather than the list of files. Basically, that means that directory scans can only be performed on server's whose default behavior is to return the list of files within that directory; provided of course there isn't an index page or that it doesn't return a 404 or other such error code.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Apr 2nd, 2008, 3:35 PM   #7
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 369
Rep Power: 0 King is an unknown quantity at this point
Re: Slide Show

Thanks for the info guys. I have chosen to use the Ajax Slide Show control.

I have one more question. In ASP, what is the best way to get a list of files from a directory? This is how I am doing it currently:
string directory = "c:/Inetpub/wwwroot/MyWebsite/test_images/";
DirectoryInfo di = new DirectoryInfo(directory);
foreach (FileInfo oFile in di.GetFiles())
{
	string fileName = oFile.Namel
	// ...
}
The problem with this is that it is relying on the filesystem and I do not know how the hosting provider will have their server setup. Is there a way where I can search the IIS virtual directory and just pass in "~/test_images" as the directory string?
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Apr 2nd, 2008, 5:03 PM   #8
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3 kruptof is on a distinguished road
Re: Slide Show

Try getting the current working directory and go from there, not sure of exact syntax but I think it goes something like this:
Directory.GetCurrentDirectory()
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Apr 2nd, 2008, 8:39 PM   #9
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 748
Rep Power: 3 Jimbo is on a distinguished road
Re: Slide Show

You can probably use Server.MapPath("~/Some/Path")
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Apr 7th, 2008, 7:27 AM   #10
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 369
Rep Power: 0 King is an unknown quantity at this point
Re: Slide Show

kruptof / Jimbo... both of those worked

Server.MapPath("~/Some/Path") did it in one less step though. Thanks guys. I now have the slide show running as desired.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
TV Show - The IT Crowd milot Coder's Corner Lounge 8 Jan 8th, 2007 10:44 PM
Size of Button before show() susam_pal Java 1 Sep 22nd, 2005 10:24 AM
Anyone watch the Drew Carey show? Sane Coder's Corner Lounge 12 Jul 10th, 2005 12:36 AM
Want to upload, show as HTML and other things.... Invisible Other Web Development Languages 4 Jun 19th, 2005 7:51 PM
how to get a little icon to show up next to your url. linuxpimp20 HTML / XHTML / CSS 1 Jun 12th, 2005 9:29 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:22 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC