This is a migrated thread and some comments may be shown as answers.

PictureBox using dynamically generated images

2 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
PJ Rodriguez
Top achievements
Rank 1
PJ Rodriguez asked on 01 Dec 2012, 12:07 AM

I have a picture box in my report. The images are dynamically generated based on the content of a query string. The problem I have is that I receive an access denied error message whenever I use a relative URL path (ie "~/test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular").

When I use an absolute path (ie "http://localhost:53657/test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular") it works with no problem.

(this works)
pictDocType.Value = "http://localhost:53657/test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular"

(this does not work)
pictDocType.Value = "~/test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular"
pictDocType.Value = "/test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular"
pictDocType.Value = "../test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular"

I want to be able to use relative paths when calling the images. Any help would be appreciated.

 

 

2 Answers, 1 is accepted

Sort by
0
PJ Rodriguez
Top achievements
Rank 1
answered on 01 Dec 2012, 12:40 AM
Update. None of those above actually worked. If I declare the picturebox.value declaratively and use absolute paths, it works. But setting up the picturebox.value programmatically does not seem to work.

Private Sub CouncilAgenda_ItemDataBound(sender As Object, e As System.EventArgs) Handles Me.ItemDataBound
        'Display Jurisdiction
 
        Dim conJurisdiction As New SqlConnection(ConfigurationManager.ConnectionStrings("CouncilAgendaConnectionString").ConnectionString)
        conJurisdiction.Open()
        Dim cmdJurisdiction As New SqlCommand("select jurisdictionname from configuration", conJurisdiction)
        Dim jurisdictionName As String
        jurisdictionName = cmdJurisdiction.ExecuteScalar
 
        conJurisdiction.Close()
 
        pictDocType.Value = "~/test/generateimage.aspx?font=2&text=ouncil Agenda&size=58&style=regular"
        pictJurisdiction.Value = "~/test/generateimage.aspx?font=1&text=" & jurisdictionName.ToString & "&size=24&style=regular"
        pictDocTypeFirstLetter.Value = "~/test/generateimage.aspx?font=2&text=C&size=88&style=regular"
         
    End Sub
0
Hadib Ahmabi
Top achievements
Rank 1
answered on 05 Dec 2012, 04:15 PM
It won't work, simply because on ItemDataBound the values are already evaluated. Try ItemDataBinding.
Relative url-s don't work declaratively, so most probably, they won't work programmatically either.
Since you can write code, why don't you just fetch the images manually and pass an Image object directly to the PictureBox's values? This should be easy enough. 
Tags
General Discussions
Asked by
PJ Rodriguez
Top achievements
Rank 1
Answers by
PJ Rodriguez
Top achievements
Rank 1
Hadib Ahmabi
Top achievements
Rank 1
Share this question
or