Solved

Displaying Images from newly created folder

Posted on 2009-04-08
2
180 Views
Last Modified: 2012-05-06
I thought I had this answered from a question I asked earlier, but I've had to revisit. I have an asp.ne/c# page that does various things. One of them is to take a powerpoint file the user has uploaded and create thumbnail images of each slide. It creates a new folder to put the images in, then is supposed to display the images on the page. I use a datalist to display the images. It was working great until the requirement came to create a new folder for each new ppt. I have everything working except the display of the images. My datalist code is attached. This used to be right, but now I need to reference a folder inside the images folder. How can I do that within this code? I have a variable available in the code behind page. Can I use it, for example ("~/")%>images/newPath/<%. . . .Thanks for any help.
<asp:DataList id-"dlImages" runat="server" RepeatDirection="vertical">

<itemtemplate>

<a href='<% ResolveUrl("~/") %>images/<%# GetFileName(Container.DataItem.ToString()) %>' target="main">

<img src='<%= ResolveUrl("~/") %>images/<%# GetFileName(Container.DataItem.ToString()) %>' id="listimage" alt="test" height="150" width="150" /></a>

</itemtemplate>

<asp:datalist>
 

GetFileName Function in code behind:
 

protected string GetFileName(string path)

{

return path.Substring(path.LastIIndexOf("\\") + 1);

}

Open in new window

0
Comment
Question by:dodgerfan
2 Comments
 
LVL 14

Accepted Solution

by:
jjardine earned 500 total points
ID: 24102314
If you are storing a variable in the code behind that has the sub folder name then you could just append that to the GetFileName function so it returns that appended to the path you are returning.

protected string GetFileName(string path)
{
     return <somevariable> + "/" + path.Substring(path.LastIndexOf("\\") + 1);
}
0
 

Author Closing Comment

by:dodgerfan
ID: 31568203
Perfect! Thank you very much.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now