我想使用ImageMap来实现图片浏览定义了一个 字符串数组,保存图片地址
private string[] imgSrc = { "~/images/histroy2010/DSCF9832.JPG", "~/images/histroy2010/IMG_9355.JPG", "~/images/histroy2010/IMG_9437.JPG", "~/images/histroy2010/IMG_9460.JPG" };private int id=0; //初始化为第一张图片 protected void Page_Load(object sender, EventArgs e)
{ this.Label1.Text = "id " + id;
this.ImageMap1.ImageUrl = imgSrc[id];
} protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
{
switch (e.PostBackValue)
{
case "previous":
Console.Out.WriteLine("previous");
id = (id - 1 + 4) % 4;
this.Label1.Text = "id " + id;
this.ImageMap1.ImageUrl = imgSrc[id];
break;
case "next":
Console.Out.WriteLine("next");
id = (id + 1) % 4;
this.Label1.Text = "id " + id;
this.ImageMap1.ImageUrl = imgSrc[id];
break;
}
}感觉没问题,可是运行的时候 id=0时,点击next,跳到第2张图片(即id=1的图片)可是在点击next 图片就不会切换了,怎么也不会跳到第3张图片;此时点击previous,却切换到第4张图片还有个问题,点击ImageMap是,整个页面都刷新,我想只是ImageMAP刷新,请问怎么实现
private string[] imgSrc = { "~/images/histroy2010/DSCF9832.JPG", "~/images/histroy2010/IMG_9355.JPG", "~/images/histroy2010/IMG_9437.JPG", "~/images/histroy2010/IMG_9460.JPG" };private int id=0; //初始化为第一张图片 protected void Page_Load(object sender, EventArgs e)
{ this.Label1.Text = "id " + id;
this.ImageMap1.ImageUrl = imgSrc[id];
} protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
{
switch (e.PostBackValue)
{
case "previous":
Console.Out.WriteLine("previous");
id = (id - 1 + 4) % 4;
this.Label1.Text = "id " + id;
this.ImageMap1.ImageUrl = imgSrc[id];
break;
case "next":
Console.Out.WriteLine("next");
id = (id + 1) % 4;
this.Label1.Text = "id " + id;
this.ImageMap1.ImageUrl = imgSrc[id];
break;
}
}感觉没问题,可是运行的时候 id=0时,点击next,跳到第2张图片(即id=1的图片)可是在点击next 图片就不会切换了,怎么也不会跳到第3张图片;此时点击previous,却切换到第4张图片还有个问题,点击ImageMap是,整个页面都刷新,我想只是ImageMAP刷新,请问怎么实现
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货