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"

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.



5/4/2009 11:17:18 PM
asp.net.web-forms 93655 articles. 3 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 12

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.
5/5/2009 1:44:03 AM

I was hoping to use the masterpage I have for this site. It doesn't use frames.



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>


Plz remember to click "Mark as Answer" if this helped you.
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.



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.
5/5/2009 3:12:51 AM

Similar Artilces:

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no rights. ...

hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. http://samples.gotdotnet.com/quickstart/aspplus/AbiBaby (Abishek Bellamkonda)=(:-*http://abibaby.wordpress.com...

Strange output in web form after web form is displayed.
   I have been using a web user control for over a week now with no problems. I am now getting strange output in my web form after my controls display on the page. Below is the strange output. Can anyone tell me what is wrong here? Note I did not include it all because it is quite large.   Request Details Session Id: l5b5vkazucfatba4oliaw1vi Request Type: POST Time of Request: 9/10/2007 4:59:59 PM Status Code: 200 Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8) Trace Information Category Message From First(s) From Last(s) aspx.page Begin PreInit aspx.page End PreInit 3.68761951588819E-05 0.000037 aspx.page Begin Init 6.36952461835233E-05 0.000027 aspx.page End Init 8.91174716339647E-05 0.000025 aspx.page Begin InitComplete 0.000105879378524366 0.000017 aspx.page End InitComplete 0.000123479380759286 0.000018 aspx.page Begin LoadState 0.000139682557420007 0.000016 aspx.page End LoadState 0.0288617687443516 0.028722 aspx.page Begin ProcessPostData 0.0289100989092189 0.000048 aspx.page End ProcessPostData 0.0364705570121342 0.007560 aspx.page Begin PreLoad 0.0365082713026376 0.000038 aspx.page End PreLoad 0.0365431919419926 0.000035 aspx.page Begin Load 0.0365610713093424 0.000018 aspx.page End Load 0.0586415312560675 0.022080 aspx.page Begin ProcessPostData Second Try 0.0586867884046715 0.000045 aspx.p...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the same functions and object of the System.Windows.Forms.Form, I have even tried having the page Inherit System.Windows.Forms.Form, and the page shows but none of the data actually populates, it just looks like a blank form...   So the question is, how do I find out more information about implementing either the full application or at least the functionality? I am not looking for someone to do the work for me, I just need to find a good starting point since I want to learn if this is possible and how to do it. Again I may not be up on all the lingo, so even giving search terms would be helpful.   Thanks, PadawangeekPadawangeekAlways learning... What you are after cannot be done.Winforms and web forms are 2 distinct technologies and their controls cannot exist together. Most of the winforms controls have an equivalent web form control, and there are some very rich we...

How to display Sql SELECT data on a web form???
Hello, i am new in ASP .NET and i want to display the SQL SELECT data. My code is: <script runat="server">   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  Dim myConnectionString As String = "Data Source = localhost; Initial Catalog = ; User Id=; Password=;" Dim myConnectionHosp As New SqlConnection(myConnectionString) If Not Page.IsPostBack Then Dim myCommand As New SqlCommand("Access", myConnectionHosp)myCommand.CommandText="SELECT UserName,id_number,fname,lname,title FROM UserTable"Dim readTupl...

How to display a pdf document inside a web form?
Hi, I need to display a pdf document inside a web form. I know how to do so using an hyperlink control (NavigateUrl property), but in this case I need to display the pdf as a result of an internal process, not the click of a link by the user. There is any way to do so? Thanks in advance.  Hi azayas48,That will be very slow. I don't recommend it. You would to use open PDF file in new window.Good Coding!Javier Luna http://guydotnetxmlwebservices.blogspot.com/ from Villa El Salvador for world! Hello, I had a similar requirement. Adobe comes with a free Active X dll (even for Reader) called AcroPDF.dll. You should be able to find this under Program Files\Adobe\Reader\active X.In my web application (.NET 1.1), I added a new COM control reference in the toolbar to this dll and placed it on the web form. You can then pass the PDf file name to the SRC property.<OBJECT>Classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" VIEWASTEXT<PARAM NAME="SRC" VALUE="<%= Me.strPAth %>"  </OBJECT>  Where Me.strPAth is a module level string int he code behind page. Good luck!!Priya.  in order to display a pdf file inside a webform u have to do the following  after certain processingResponse.Clear();string filePath = ur file path on the server Response.contentType = "application/pdf";Response.WriteFile(filePath);Happy CodingHaissam Abdul ...

How to display SQL Server Error Message on Web Form
I have following Stored Procedure ... How do I display Error Message Return by Stored Procedure ?? CREATE PROCEDURE [AddNewUserDetails] ( @UserName nvarchar(30), @Passcode nvarchar(10), @FName nvarchar(30), @LName nvarchar(30), @UserRoleID int, @AccStatus nvarchar(50) ) AS IF EXISTS ( SELECT 'TRUE' FROM UserDetails where logname = @UserName) BEGIN -- Notify user about duplicate username SELECT 'Username already exists' END ELSE BEGIN -- Username doesn't exists in database, add it and notify admin SELECT 'Record Added' DECLARE @userid int SELECT @userid = MAX(userid) + 1 FROM UserDetails INSERT INTO UserDetails VALUES (@userid, @UserName, @Passcode, @FName, @LName, @UserRoleID, @AccStatus) END GO Here is the code for Calling Stored Procedure public string AddNewUserDetails(string UserName, string Passcode, string FName, string LName, int UserRoleID, string AccStatus) { // Create Instance of Connection and Command Object SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); SqlCommand myCommand = new SqlCommand("AddNewUserDetails", myConnection); // Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC SqlParameter parameterUserName = new SqlParameter("@UserName", SqlDbType.NVarChar, 50); parameterUserName.Value ...

Finishing Touches on Displaying a PDF file in a Web Form
I've successfully built a web app that creates a PDF file on-the-fly and then displays it in a web form.  Here's the core of my code:        // First create the report in PDF format        CrystalDecisions.Shared.DiskFileDestinationOptions destOptions = new CrystalDecisions.Shared.DiskFileDestinationOptions();        string filename = Session["ReportFilename"].ToString();        destOptions.DiskFileName = filename;   ...

Displaying Image from SQL Server on Mobile Web Form
Hi,I'm new to mobile web development and need some kick start on  "Displaying Image from SQL Server on Mobile Web Form".... Please help me out. Thanks    Hi, I have code which retrieves the images from sql server and displays it on the mobile web form. Hope this helps.   byte[] data = new byte[0];  SqlConnection conn = null;       string doxtopDbConn = ConfigurationManager.AppSettings["doxtopDbConn"];             try   &nb...

getting start with vb.net and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

Getting data form SQL Server 2005 to a Web.SiteMap file
I want read a hierarchal data table in SQL Server 2005 to write My Web.SiteMap file. How I to do it? web.sitemap is a static file used by the XmlSiteMapProvider if you know your site navigation at development time. If you have a data-driven navigation, then you should consider creating your own SiteMapProvider. -Brock  DevelopMentorhttp://staff.develop.com/ballen...

Changed values not getting passed to UPDATE SQL function on web form
So I have a form that has been giving me fits... It's a form to edit a database entry; on Page_Load, data from the entry loads on the page in various fields (textboxes, drop-down lists, radio button lists, etc). The idea is that the user should be able to upate that data as needed, then hit a "save" button, and an UPDATE query saves the new data to the database. What's happening instead, however, is that the old unchanged data is being passed to the UPDATE query, rather than the new data. Except in one wierd case, when a record is created with only the bare minimum of inf...

VB .net Web Form will not get contents of Text Box
I have created a web form with text boxes that are bound to a DataSet/DataView.  I have created button to navigate up and down the recordset.  That all works fine. I need to have the ability to edit/add text in any of the boxes and then when clicking "Save" button, it would build an UPDATE query to send to the database. When the Save button is clicked, I have coded to DIM a string var (strSQL) to use to build the SQL command.  For some reason, it will only get the text from a text box if the data was pulled the database.  If I add/edit data, then the SQL command will ha...

CR 9 for VS.NET PDF problems using web forms
Hi all. I am trying to capture patient history data then summarize the data in a one page report using Crystal Report. I would like to use Adobe Plug-in to alllow for printing the report (although printing from the browser will be acceptable). I am using the code straight off of the web site: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myExportOptions As CrystalDecisions.Shared.ExportOptions Dim myDiskFileDestination As CrystalDecisions.Shared.DiskFileDestinationOptions Dim myExportFile As String Dim myReport As New SurgeryQuestReport 'exports file to disk in PDF format myExportFile = "C:\My Documents " & Session.SessionID.ToString & ".pdf" myDiskFileDestination = New CrystalDecisions.Shared.DiskFileDestinationOptions myDiskFileDestination.DiskFileName = myExportFile myExportOptions = myReport.ExportOptions With myExportOptions .DestinationOptions = myDiskFileDestination .ExportDestinationType = .ExportDestinationType.DiskFile .ExportFormatType = .ExportFormatType.PortableDocFormat End With myReport.Export() Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.WriteFile(myExportFile) Response...

IN VS.Net how can i get a web form to scroll (design mode)
In design mode in VS.Net, there is a scroll bar next to the web form, but it is grayed out.  I can not figure out how to enable it.  I want to design a web form that is larger in size than the surface area shown in teh deisgn window.  Can someone help out with this?Thank you. VS design surface shows how the page is going to be rendered in the browser. Therefore, there is no 'virtual' large size. In the browser scroll bar appears if the browser window is smaller than the page content. You can make scroll bar to appear by enclosing page content in a large container e...

.NET 1.1 Web Form
I am scratching my head trying to figure out why my events button (Lighting Bolt) is not displaying when I select buttons in Visual Studio 2003.  Has anybody had this happen before? I am tired into Visual Source Safe and wonder if that has anything to do with it?Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ Ummm>>>   That is the difference between C# and VB.NET.  VB.NET does not display the Lightning Bolt under properties in VS 2003.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/...

Get back to web form from a Response.ContentType = "application/pdf"
Hi, My last page of my ecommerce site, called Confirmation.aspx, has one button which allows user to print an order confirmation. I am exporting a report as a pdf file. My code brings up the adobe acrobat into the browser. The user prints out the order confirmation. How do I get back to the web page , Confirmation.aspx? When I hit the Back button on the browser, it goes back to far. Is there a way to call adobe acrobat separate from the browser? Below is my subroutine. Thanks, poc1010 Public Function ReportPDF(ByVal myreport As CrystalReport1) Dim myExportO...

Where to order the table values displayed in a web form object? In Sql Server or in the Application?
Hi, I have a table in my database with several car types, and the order I want for that table is: Car_typeA_1 Car_typeA_2 Car_typeA_3 Car_typeA_4 Other_Cars_typeA Car_typeB_1 Car_typeB_2 Car_typeB_3 Other_Cars_typeB Car_typeC_1 Car_typeC_2 Car_typeC_3 Car_typeC_4 Car_typeC_5 Other_Cars_typeC .... This table is more or less always the same, but from time to time I want to add a new car type, for instance; Car_typeA_5, but this new type must be located under the last register, in the example under ‘Other_Cars_typeC’. So, now the order i...

Vs.net 2008 - web setup project
Hi,  I created a web setup (not web deployment) project in VS.net 2008; I noticed that PDF files in a folder is not getting added part of the websetup output. In the same folder, I have images, text files, they are all included. Does any one know, how to include PDF Files and other files, part of the websetup project? Regards, Sreedhar Hi, What type of your ASP.NET project is? I guess it is ASP.NET web application. If so, the pdf file is not copy to output directory by default, because it is not treated as "Content" of Build Action. To work around this issue, we can se...

getting values from a web form to windows form
Hot Requirement ..... Is there any possible of getting values from a web form to windows form ????? Yes One way i to use the WebRequest and WebResponse classes of the System.Net namespace. For example:  WebRequest request = WebRequest.Create("URL of the web page); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadLine(); ....    Reza Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way fut...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. There is no direct way to do that.Regards,Krishna Kishore.  View My Blog You have to create UI buddy. Functionality you can seperate from current applicaiton and can make assembly on which your UI will run or if functinality is already built as DLL then you have to work around com interoperability of .NET Hope this help. Never Ever Overloaded...

Populating a pdf form with data from a web form
Problem: How do I populate a pdf with data from a web form? I have created a web form that functions in the following ways:User navigates to the registration part of the site and fills out form data (i.e. First, Last Name, Phone, Organization, City, State, etc.). Upon hitting the submit button a subroutine is executed and an automated email is sent to our marketing director, notifying her of the registration taking place. Simultaneously the Submit button also opens a pdf that the user is to print out and mail us (along with their payment) to complete their registration. For usability purpose...

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/databases.aspxRegards Mike [MVP - ASP/ASP.NET]My site...

Using .Net 2.0 and System.Web.UI.WebControls.Treeview with SQL Reporting Services 2005 for navigation and display.
I spent several hours sifting through article after article about how to build tree navigations dynamically.  They assumed that the order of the data coming in was 'orderly' and that you were usually using the IE Web Control toolkit which is a .Net 1.0 package.  In our environment 2.0+, that would not work for us and we needed to ensure browser compatibility.  Thanks to a colleagues suggestion of recursion, I came up with the following code below.  It's length is due to all the detailed commenting.  Feel free to comment on it, any positives or...

Web resources about - Display pdf in a div after getting it from sql - asp.net.web-forms

Samples of display typefaces - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Those giant displays in the new Ive-designed Apple Stores reportedly cost $1.5M each
The giant screens that form part of the new Apple Store design created by Jony Ive reportedly cost $1.5M each. We got out first look at the screens ...

Right on schedule, AMOLED displays are now cheaper to produce than LCD
... better colors, higher contrast and deeper saturation than LCD. The biggest barrier stopping AMOLED from taking over as the smartphone display ...

'Next-generation' Apple Store opens in Memphis with custom 37-foot display
... to land stateside, and AppleInsider has exclusive photos of the logo-less facade, custom wooden wall installations and massive 37-foot TV display ...

Nissan's Skyline GT-R display is every Gran Turismo player's fantasy
Filed under: New York Auto Show , Nissan , Coupe , Performance Nissan has the best display at the New York Auto Show , and it's absolutely because ...

VIZIO P-series 4K TV displays have integrated 'Google Cast' technology
While smart televisions and displays are becoming more commonplace, it is becoming increasingly clear that they are not created equal. In other ...

Apple is running out of reasons to not upgrade the iPhone’s display to AMOLED
Several rumors in recent months have indicated that Apple is planning to give its flagship phone an AMOLED display sometime within the next couple ...

Yahoo is the only search company expected to shrink in display and search revenue next year
Here's some more bad news for Yahoo. Yahoo's net search and display advertising revenues are expected to shrink this year, while the rest of ...

Apple erects giant display worth $1.5 million in ‘next-gen’ retail store
Whether it’s adding tree-lined avenues in store, or high-tech display tables for showing off the Apple Watch or new iPhone, the design of the ...

China market: LG Display tops TV panel suppliers in 2015, says Sigmaintell
LG Display, among TFT-LCD panel makers, shipped the most LCD TV panels in the China market in 2015, followed by Innolux, BOE Technology and Samsung ...

Resources last updated: 3/30/2016 4:29:13 AM