Display pdf in a div after getting it from sql


Hi all
I have this very simple little page where I get a pdf file from a SQL Server database and display that file on the page. Here is the code. <%
Dim Var1 As String
Var1 = Request.QueryString("ArticleID")
SqlDataSource1.SelectParameters("ArticleID").DefaultValue = Var1
Dim dt As System.Data.DataView
dt = SqlDataSource1.Select(DataSourceSelectArguments.Empty)
Dim docbyte As Byte()
docbyte = dt(0)(0)
Response.ContentType ="application/pdf"
Response.BinaryWrite(docbyte)
Response.End()
%>
I have now been asked if I can display the file on a page which contains other standard site content such as ads, menu bar, header and so on. So the best way I can see to do this is to try to figure out how to display this content in a DIV.
Does it make sense to do it this way? How would I do it? I want to keep the code as simple as possible, and I would prefer to do it all with inline code versus any code-behind files.
Thanks
Richard
-1
RMcBride
5/4/2009 11:17:18 PM
πŸ“ asp.net.web-forms
πŸ“ƒ 93655 articles.
⭐ 6 followers.

πŸ’¬ 5 Replies
πŸ‘οΈβ€πŸ—¨οΈ 4788 Views



Try using frames.Β  Set the src attribute of the frameΒ to be your aspx file that generates the pdf file.

Plz remember to click "Mark as Answer" if this helped you.
1
Ugly
5/5/2009 1:44:03 AM

I was hoping to use the masterpage I have for this site. It doesn't use frames.
Thanks
Richard
1
RMcBride
5/5/2009 2:01:15 AM


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<object data="URL OF YOUR ASPX PAGE THAT GENERATES THE PDF" type="application/pdf"></object>
</asp:Content>

Plz remember to click "Mark as Answer" if this helped you.
0
Ugly
5/5/2009 2:20:05 AM

Hi There
I like the idea, but I am going to have to play with it for a bit. For example, how would I handle the passing of the querystring? In the original code, I get a querystring from the calling page and use that as a parameter to request the file from SQL.
I almost wonder if I could make a user control out of this little routine somehow. Then I could just call the control, but I would still have to pass it the ArticleID. Hmmmmm.
Thanks
Richard
1
RMcBride
5/5/2009 3:06:50 AM
You can always bind the Data Attribute in the code behind and append the querystring value to the URL there.

Plz remember to click "Mark as Answer" if this helped you.
-1
Ugly
5/5/2009 3:12:51 AM
Reply: