Is there a way to dynamically load multiple images from a folder in ASP.Net based on the selected option in a dropdown list? I'm trying to implement this in Visual Studio and need some help. Below is the code I've been working with, but I'm open to suggestions for improvement or modifications. Additionally, I want to bind the image output to an image button control as a slideshow.
<script type="text/javascript">
function new1(city) {
switch (city) {
case "Patna":
var imlocation = "Patna/";
var currentdate = 0;
var image_number = 0;
function ImageArray(n) {
this.length = n;
for (var i = 1; i <= n; i++) {
this[i] = ' '
}
}
image = new ImageArray(2)
image[0] = '2.jpg'
image[1] = '3.jpg'
var rand = 60 / image.length
function randomimage() {
currentdate = new Date()
image_number = currentdate.getSeconds()
image_number = Math.floor(image_number / rand)
return (image[image_number])
}
document.write("<img src='" + imlocation + randomimage() + "'>");
case "Bhopal":
var imlocation1 = "Bhopal/";
var currentdate1 = 0;
var image_number1 = 0;
function ImageArray1(n) {
this.length = n;
for (var i = 1; i <= n; i++) {
this[i] = ' '
}
}
image1 = new ImageArray1(3)
image1[0] = '2.jpg'
image1[1] = '4.jpg'
image1[2] = '1.jpg'
var rand1 = 100/ image1.length
function randomimage1() {
currentdate1 = new Date()
image_number1 = currentdate1.getSeconds()
image_number1 = Math.floor(image_number1 / rand1)
return (image1[image_number1])
}
document.write("<img src='" + imlocation1 + randomimage1() + "'>");
}
}
<asp:DropDownList ID="DropDownList1" runat="server" onchange="new1(this.value)"
DataSourceID="SqlDataSource1" DataTextField="City" DataValueField="City"
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True" >
</asp:DropDownList>