daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Aug 29th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // .aspx
  2. <asp:Repeater ID="BannerRepeater" runat="server">
  3.     <ItemTemplate>
  4.         <asp:Image
  5.             ID="Image1"
  6.             ImageUrl='<%# "res/img/banner/" + Eval("Name") %>'
  7.             runat="server"
  8.             AlternateText="bannerimg"
  9.             CssClass="bannerImg" />
  10.     </ItemTemplate>
  11. </asp:Repeater>
  12.  
  13.     // .cs
  14.         string root;
  15.         List<FileInfo> files;
  16.        
  17.         protected void Page_Load(object sender, EventArgs e)
  18.         {
  19.             if (!IsPostBack)
  20.             {
  21.                 files = new List<FileInfo>();
  22.                 root = System.Web.HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"];
  23.  
  24.                 foreach (string file in Directory.GetFiles(root + @"res\img\banner", "*.jpg"))
  25.                     files.Add(new FileInfo(file));
  26.  
  27.                 BannerRepeater.DataSource = files;
  28.                 BannerRepeater.DataBind();
  29.             }
  30.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top