Guest User

Untitled

a guest
Jan 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.IO;
  8. using System.Text;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12.  
  13. public partial class _Default : System.Web.UI.Page
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         DirectoryInfo imgFiles = new DirectoryInfo(Server.MapPath("~/images/"));
  18.         FileInfo[] fileName = imgFiles.GetFiles("*.jpg");
  19.  
  20.    if (!IsPostBack)
  21.             {
  22.                 imgBox.ImageUrl = ("~/images/default/default.jpg");
  23.                 foreach (FileInfo i in fileName)
  24.                 {
  25.                     listFiles.Items.Add(Path.GetFileNameWithoutExtension(i.Name));
  26.                 }
  27.             }
  28.     }
  29.    
  30.    
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  protected void listFiles_SelectedIndexChanged(object sender, EventArgs e)
  39.     {
  40.         imgBox.ImageUrl = ("~/images/" + listFiles.SelectedItem.Text + ".jpg");
  41.     }
  42. }
Add Comment
Please, Sign In to add comment