Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8440325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:15:46+00:00 2026-06-10T08:15:46+00:00

I have a script that shows some files from a folder. code behind Sub

  • 0

I have a script that shows some files from a folder.

code behind

Sub fileinfo()
    Dim objDI As New System.IO.DirectoryInfo(Server.MapPath("upload/files/"))
    Dim allFile As New ArrayList()
    allFile.AddRange(objDI.GetFiles("*.png"))
    allFile.AddRange(objDI.GetFiles("*.jpg"))
    allFile.AddRange(objDI.GetFiles("*.bmp"))
    allFile.AddRange(objDI.GetFiles("*.gif"))
    allFile.AddRange(objDI.GetFiles("*.pdf"))
    allFile.AddRange(objDI.GetFiles("*.doc"))
    allFile.AddRange(objDI.GetFiles("*.docx"))

    Me.showfiles.DataSource = allFile
    Me.showfiles.DataBind()
End Sub

main code

<ul class="thumbnails">
   <asp:DataList ID="showfiles" runat="server" RepeatColumns="6" CellPadding="10" RepeatLayout="flow">
         <ItemTemplate>
               <li class="span2"><a class="thumbnail" href="#"><asp:ImageButton ID="folderfiles" runat="server" ImageUrl='<%# string.Format("upload/files/{0}", DataBinder.Eval(Container.DataItem,"Name")) %>' ToolTip='<%# Bind("Name") %>' height="82" width="119" /></a></li>
         </ItemTemplate>
  </asp:DataList>

works fine with images, but if i add a document like a pdf file i get this.
https://i.stack.imgur.com/g9bT4.png

then it add the textbox, how can i add an if statsment or something that can add:

pdficon.jpg for .pdf files

docicon.jpg for .doc files

zipicon.jpg for .zip files

so if the file is an image then it works like now, and when the file is an pdf or doc file, then it use the icon image and display that !?

…..EDIT…..EDIT……EDIT……..EDIT………EDIT………EDIT

Thx its works
https://i.stack.imgur.com/SKL55.png

but when i click one of the files i get and error page, with no error number, but a text with.

………. <%@ Page EnableEventValidation=”true” %> ClientScriptManager.RegisterForEventValidation …..

I cant download/See the image/pdf file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:15:48+00:00Added an answer on June 10, 2026 at 8:15 am

    You can implement a method returning your image url like this:

    Private Function getImageUrl(filename As String) As String
    
        Select Case Path.GetExtension(filename)
            Case "pdf"
                Return "pdficon.jpg"
            Case "doc"
                Return "docicon.jpg"
            Case "zip"
                Return "zipicon.jpg"
        End Select
    
        Return String.Format("upload/files/{0}", filename)
    End Function
    

    and use it in your markup:

    … ImageUrl='<%# getImageUrl(DataBinder.Eval(Container.DataItem,"Name")) %>' …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this little script that shows one wisdom each day. so I have
I have problem with php script. The thing is that it shows me, that
I have the script shown below that displays a list of records from a
I have a script that recursively loops through all the sub directories and compresses
I have following script that executes all the .reg files in the current directory.
I am working on a script that downloads various image files from the web
I have a PHP script which downloads files to the client, in a new
I have some sensitive files that I want the web server to be able
I have a script that loops through many url based XML files to compare
I have a POSH script that sets a user's access to a specific folder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.