Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Trying to display images from database..how do I?Trying to display images from database..how do I?
Previous
 
Next
New Post
4/13/2009 10:34 AM
 

Hello Everyone,

I am a newbie as far as DNN module development is concerned, although I have been doing ASP.net programming for over 5 years. We are currently in the process of moving all our existing sites to DNN. There is one application that I am having some trouble converting due to my lack of knowledge about DNN modules.

Heres how the application works.

The user logs in and we present to him the about 9-10 different categories of images to choose from, he picks one and this category has about 5-15 subcategories. When he clicks on any one sub-category, we show him a preview thumbnail and a download link.

We store all the images and categories/subcategories in DB. Our current ASP.Net 2.0 application uses an aspx page to display the image using the Response object. (Code for the GetImage.aspx.vb is at the bottom of this posting)

I have made the module with a view control to display the first set of categories. On this view page, i need to create hyperlinks to this GetImage.aspx to display the images. I have made the GetImage a control in my custom module and declared it in the Module definition page. I am not sure what to do next. How do I link from this ViewModule to the GetImage page in my image links so that GetImage will display the images on the view control?

Please point me in the right direction, also let me know if you need to see more code.

Thanks

Sid

---------------------------------------------------------------- GetImage.aspx.vb -----------------------------------------------------------

 

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadTry

 

If Not Page.IsPostBack Then

Initialize()

 

End If

 

ProcessModuleLoadException(

 

Catch exc As ExceptionMe, exc)End Try

 

End Sub

 

 

Private Sub Initialize()If Not Request.QueryString("i") Is Nothing Then

 

 

 

Dim picID As Integer = System.Convert.ToInt32(Request.QueryString("i"))Dim bHiRes As Integer = 0If (Request.QueryString("h") = "1") Then

bHiRes = 1

 

End If

 

 

Dim DEDataAccessObj As New DEDataAccess(Utility.DbConnectionStringExtranet)If (picID > 0) Then

 

Dim dtKinds As DataTable = Nothing

 

 

Select Case Request.QueryString("t").ToUpper()Case "M"

dtKinds = DEDataAccessObj.GetPictureByProductModelID(picID, bHiRes)

 

Case "K"

dtKinds = DEDataAccessObj.GetPictureByProductKindID(picID, bHiRes)

 

Case "P"

dtKinds = DEDataAccessObj.GetPictureByID(picID, bHiRes)

 

End Select

 

If dtKinds Is Nothing Then

 

Return

 

End If

 

If dtKinds.Rows.Count > 0 Then

 

 

Dim kindDataRow As DataRow = dtKinds.Rows(0)Dim image As Byte() = Nothing

 

If (kindDataRow("Picture").GetType().Name <> "DBNull") Then

image = kindDataRow(

 

"Picture")End If

 

If (Not image Is Nothing) Then

 

'Adjust content headers so that High Res images

 

' are sent for download (not displayed in browser)

 

If (bHiRes) Then

Response.AddHeader(

Response.AddHeader(

 

"Content-Disposition", "attachment; filename=" & kindDataRow("OriginalFileName"))"Content-Length", image.Length)End If

Response.ContentType =

"image/jpeg"

Response.BinaryWrite(image)

 

Else

Response.ContentType =

"image/jpeg"

 

'Response.BinaryWrite()

 

End If

 

End If

 

End If

 

End If

 

End Sub

-----------------------------------------------------------------------------------------------------------------------------

 

 
New Post
4/13/2009 12:32 PM
 

You should keep GetImage as a separate page, and link to it the same as you were before.  Don't register it as a control with DNN.

To get the correct path, you may need to call ResolveUrl("~/DesktopModules/YourModuleName/GetImage.aspx"), but otherwise it should be very similar to what you were doing before.

Hope that helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Trying to display images from database..how do I?Trying to display images from database..how do I?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out