根据 asp.net 中的下拉列表选择选项从文件夹动态加载多个图像。谁能帮我在visual studio中实现这个?这是我尝试过的代码,帮助我更好的选择或修改它,我还需要将图像输出绑定到图像按钮控件作为幻灯片。
<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>