CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Change image based on file type

Print topic Send  topic

Author Message
JimbobGilb

Posts: 28
Posted: 12/21/2011, 1:26 AM

I would like to change an image based on the file extension type. The user can upload and image or a .pdf file for example. If it is and image then its fine and displays the image but if it is not like a .JPG I would like the default image to be download.jpg but cannot filter it based on the extension type. How can I get it to just look at the file type.

Eg

If facilities.ImageLink1.Value <> ".JPG" then facilities.ImageLink1.Value ="Download.jpg"
View profile  Send private message
Vincent

Posts: 31
Posted: 03/26/2012, 12:22 AM

Use the control's BeforeShow Event and add some custom code. Here's what I did to show an icon as the filetype

  
Function tasks_Label_Attachment_BeforeShow(Sender) 'tasks_Label_Attachment_BeforeShow @9726-78516DC3  
  
'Get Original Filename @9754-7858E0C6  
    Dim nPos, FileName  
    nomdufichier = tasks.Label_Attachment.Value  
    FileName = tasks.Label_Attachment.Value  
    nPos = InStr(FileName,".")  
    If nPos > 0 Then  
        FileName = Mid(FileName,nPos+1)  
        tasks.Label_Attachment.Value = FileName  
    End If  
'End Get Original Filename  
  
'Custom Code @9757-73254650  
' -------------------------  
Dim nomdufichier  
If Right(tasks.Label_Attachment.Value,3) = "jpg" then  
	tasks.Label_Attachment.Value = "<a href=""uploadedfiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/JPG.png"" height=""32"" width=""32"" alt=""" & FileName &""" /></a>"  
elseif Right(tasks.Label_Attachment.Value,3) = "png" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/PNG.png"" height=""32"" width=""32"" alt=""" & FileName & """ /></a>"  
elseif Right(tasks.Label_Attachment.Value,3) = "zip" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/ZIP.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,3) = "xls" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/XLS.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,3) = "doc" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/DOC.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,4) = "xlsx" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/XLSX.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,4) = "docx" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/DOCX.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,3) = "mp3" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/MP3.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,3) = "pdf" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/PDF.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
elseif Right(tasks.Label_Attachment.Value,3) = "txt" then  
	tasks.Label_Attachment.Value = "<a href=""UploadedFiles/"& nomdufichier &""" title=""Please click to download " & FileName & """><img style=""vertical-align:middle;"" src=""images/Icons/TXT.png"" height=""32"" width=""32"" alt=""" & FileName & """ />"  
End If  
' -------------------------  
'End Custom Code  
End Function 'Close tasks_Label_Attachment_BeforeShow @9726-54C34B28  


View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.