Put your images in a folder named "Image" in project..
private static DirectoryInfo dir;
private static FileInfo[] images;
private static int currIndex=0;
private static int count=0;
protected void Page_Load(object sender, EventArgs e)
{
dir = new DirectoryInfo(Server.MapPath("Image"));
images = dir.GetFiles();
count = images.Length;
if (!IsPostBack)
{
if (count > 0)
{
string strImageurl = images[currIndex].Name;
strImageurl = "~/Image/" + strImageurl;
Image1.ImageUrl = strImageurl;
}
}
}
protected void submitbtn_Click(object sender, ImageClickEventArgs e)
{
if (count > 0)
{
if (currIndex ==(count-1))
{
currIndex = 0;
}
else
{
currIndex++;
}
string newUrl = images[currIndex].Name;
newUrl = "~/Image/" + newUrl;
Image1.ImageUrl = newUrl;
}
}
<asp:Button ID="submitbtn" runat="server" onclick="submitbtn_Click" Text="Submit" />
<asp:image ID="Image1" runat="server" Height="375px" Width="500px"></asp:image>
at page load this will load fist image in image folder to image control and on sumbit button click load next image and this will go on in cyclic way....