Stop To Open Dynamically Created PDF In Browser

Oct 19, 2010

i create a pdf dynamically it's perfect but the problem is that i want to open this pdf in popup but it cant't open in popup it open direct in browser. my code is below.

CLASS file
public class clsCreatePDF
{
public clsCreatePDF()
{
//
// TODO: Add constructor logic here
//
}
public string CreatePDF(string imagename)
{
HttpContext.Current.Response.ContentType = "application/pdf";
Document doc = new Document();
string fileName = Convert.ToString(DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond);
//string te = HttpContext.Current.Request.PhysicalApplicationPath + "PostCard\PostcardPDF\" + fileName + ".pdf";
PdfWriter.GetInstance(doc, new FileStream(HttpContext.Current.Request.PhysicalApplicationPath + "PostCard\PostcardPDF\" + fileName + ".pdf", FileMode.Create));
PdfWriter.GetInstance(doc, HttpContext.Current.Response.OutputStream);
doc.Open();
PdfPTable maintable = new PdfPTable(1);
maintable.DefaultCell.BorderColor = iTextSharp.text.BaseColor.BLACK;
// maintable.DefaultCell.Height = Convert.ToSingle(306)
//maintable.DefaultCell.PaddingTop = 10
///'''''''''''' inner table start '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PdfPTable table = new PdfPTable(3);
maintable.AddCell(table);
table.DefaultCell.BorderColor = iTextSharp.text.BaseColor.WHITE;
// table.DefaultCell.Padding = 10
//PdfPCell imageCell1_1 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/smallimages/2257Bluehills.jpg")), true);
PdfPCell imageCell1_1 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/smallimages/" + imagename )), true);
imageCell1_1.Colspan = 2;
imageCell1_1.BorderColor = iTextSharp.text.BaseColor.WHITE;
imageCell1_1.VerticalAlignment.ToString("middle");
imageCell1_1.Border = 0;
imageCell1_1.PaddingLeft = 12;
imageCell1_1.PaddingTop = 12;
imageCell1_1.PaddingBottom = 0;
table.AddCell(imageCell1_1);
PdfPCell imagecell1_2 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/garmond1.jpg")), true);
imagecell1_2.BorderColor = iTextSharp.text.BaseColor.WHITE;
imagecell1_2.Border = 0;
table.AddCell(imagecell1_2);
// table.AddCell("1.2")
//PdfPCell imageCell2 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/bigimages/2257Bluehills.jpg")), true);
PdfPCell imageCell2 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/bigimages/"+ imagename )), true);
imageCell2.Colspan = 3;
imageCell2.BorderColor = iTextSharp.text.BaseColor.WHITE;
imageCell2.Border = 0;
imageCell2.PaddingTop = 12;
imageCell2.PaddingLeft = 30;
imageCell2.PaddingRight = 30;
table.AddCell(imageCell2);
//table.AddCell("1.3")
//table.AddCell("1.4")
//table.AddCell("2.1")
//table.AddCell("2.2")
// table.AddCell("")
PdfPCell imagecell3_1 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/garmond1.jpg")), true);
imagecell3_1.BorderColor = iTextSharp.text.BaseColor.WHITE;
imagecell3_1.Border = 0;
table.AddCell(imagecell3_1);
//table.AddCell("")
//PdfPCell imageCell3_2 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/smallimages/2257Bluehills.jpg")), true);
PdfPCell imageCell3_2 = new PdfPCell(Image.GetInstance(HttpContext.Current.Server.MapPath("~/PostcardImage/smallimages/" + imagename )), true);
imageCell3_2.Colspan = 2;
imageCell3_2.BorderColor = iTextSharp.text.BaseColor.WHITE;
imageCell3_2.Border = 0;
imageCell3_2.PaddingTop = 12;
imageCell3_2.PaddingRight = 12;
table.AddCell(imageCell3_2);
//table.AddCell("2.3")
//table.AddCell("2.4")
//table.AddCell("3.1")
//table.AddCell("3.2")
//table.AddCell("3.3")
//table.AddCell("3.4")
///'''''''''''''''''''''''''''''''' inner table clase''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PdfPCell mainimgcell = new PdfPCell(table);
// mainimgcell.Colspan = 2
//maintable.AddCell("hi")
//mainimgcell.BorderColor = iTextSharp.text.BaseColor.RED
doc.Add(maintable);
//doc.Add(table)
doc.Close();
// HttpContext.Current.Response.Redirect("PostcardPDF/" + fileName + ".pdf");
return fileName;
}
}
CS page
if (imgupload.FileContent.Length > 0)
{
string fileName = "";
string pdfname = "";
//set Imagename by adding milliseconds too so that no overwrite in images directory.
fileName = DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond + Path.GetFileName(imgupload.PostedFile.FileName.ToString().Trim());
//Resize images and store it in different directories
ResizeImages objResizeImage = new ResizeImages();
objResizeImage.ResizeImage(fileName, imgupload.PostedFile.InputStream);
objResizeImage = null;
//*****************************Create PDF **************
clsCreatePDF objcreatepdf = new clsCreatePDF();
pdfname = objcreatepdf.CreatePDF(fileName);
Session["pdfname"] = pdfname;
objcreatepdf = null;
//*****************************end *********************
}

ASPX page is below

<tr>
<td>
</td>
<td>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" PostBackUrl="~/usermodule/Dashboard.aspx" />
<asp:Button ID="btnCreate" runat="server" Text="Create and Preview New PostCard"
OnClick="btnCreate_Click" />
<asp:Button ID="btnshow" runat="server" Style="display: none" />
<cc1:ModalPopupExtender ID="popupProductDetails" runat="server" PopupControlID="pnlPostcard"
BackgroundCssClass="modalBackground" TargetControlID="btnshow" CancelControlID="btnCancelProductDetails" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Panel ID="pnlPostcard" CssClass="modalPopup" runat="server" Width="80%" Height="80%"
Style="display: none">
<table>
<tr>
<td>
<iframe id="Postcardframe" runat="server" scrolling="yes" width="750px;" height="100%">
</iframe>
</td>
</tr>
<tr>
<td style="text-align: right; width: 10%;">
<asp:Button ID="btnCancelProductDetails" Text="Cancel" runat="server" />
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>

View 3 Replies


Similar Messages:

Stop Pdf To Open In Browser When Creating Dynamically

Oct 20, 2010

i create a pdf file dynamically but when it create it open in browser directly , i don't want to open this in browser. but it open in a popup.

View 6 Replies

C# - How To Open The Download Window When A Dynamically Created Link Is Clicked

Apr 27, 2010

i have stored the txtfile in the database.i need to show the txtfile when i clik the link. and this link has to be created dynamically.

my code below:

aspx code:

[code]....

i have got the link dynamically, but i did not able to download the txtfile when i clik the link. how to carry out this.

View 2 Replies

Web Forms :: Open PDF File Directly In Browser Without Open Save Dialog?

Feb 22, 2013

I have created a pdf file using aspose and need to open it without saving the pdf.Is it possible.

View 1 Replies

Web Forms :: Use Dynamically Created Controls Such As A Checkbox List And Fill The Values Dynamically?

Sep 28, 2010

I'm creating an quiz application which queries the database and extracts the questions and choices. I use dynamically created controls such as a checkbox list and fill the values dynamically. How do I do this? Right now I have these functions:

array_random_init(); this creates a 10 element integer array from 1-20 - extract_question(i): this extracts a question indexed at i in DB, I created the controls and set the appropriate text in this function. - validate_question(i); this is called by button_click and validates the question i according to DB.

I understand I have to recreate the controls in Page_init on postback, but what should it look like? Do I need to add "if IsPostBack" in page_init, or do I create the controls in page_init() and reset their properties in page_load when I use extract_question(i)? Also, I cannot seem to clear the selected boxes on postback, I added page directive "enableviewstate=false" but it doesn't work.

View 2 Replies

Web Forms :: How To Use AddHandler To Dynamically Assign Events To Dynamically Created Buttons

Feb 14, 2011

I have a website that sales associates access to view account information with clients. S.A's can only view information for accounts that they are tied to. Some clients have more than one account, S.A's can be tied to more than one account, but not all accounts of one client need to be tied to one S.A.

On the account info pages, I have account numbers (dynamically displayed labels) displayed of other accounts that the account client is associated with, which the S.A's can see. I'm modding this so that if the S.A has viewing permissions of any of the other accounts on that list of accounts, that instead of a label being displayed, a button directing them to that account page will display instead. In order for this to work, I have to attach a security function to the button, otherwise the page will blow out on the S.A's.

So I'm running a piece that is displaying a button instead of a label, which is working fine. My problem is when I try to attach the security event to the dynamically displayed buttons. It seems that the page just posts back and doesn't execute my code at all.

On my Page_Load, I'm running this after the buttons and labels are displayed:

For x = 0 to tblAccountList.Rows.Count - 1
'use a try to target the button, use catch to handle if it's instead a label, only one cell per row.
Try
Dim accountLink as Button = tblAccountList.Rows(x).Controls(0)
Addhandler accountLink.Click, AddressOf Me.PermissionViewCheck
Catch ex as InvalidCastException
Continue For
End Try
Next

I don't have any code checking for postbacks or anything like that, but the "PermissionViewCheck" event never fires and just reposts the page.

View 6 Replies

Way To Stop Browser History Population In A Textbox?

Jan 26, 2011

way to stop browser history population in a textbox?

View 4 Replies

Stop Browser From Filling Textboxes With Details?

Apr 13, 2010

I've got an ASP.NET application which allows users to enter their username/password in various places (e.g. login, change password, change username etc..). When I logged in, the browser asked if I would like to store the user details. Usually, I click 'no', but this time I decided to click 'yes'. Now, certain textboxes in my form are prefilled with the username or password. Is it possible to remove these, as they sometimes appear in textboxes which shouldn't be prefilled. I tried setting AutoCompleteType=none and Text='' but it still gets prefilled. The textboxes don't have much in common, except the same CssClass and, for password boxes, TextMode=password. The names are different, although sometimes they include the word name (e.g. fullName, userName). Is there a way to stop the browser from filling certain textboxes?

View 2 Replies

Web Forms :: How To Stop The Browser From Remembering The Wrong Information

Mar 8, 2010

I have a page with some controls and a next button. When the entered information does not match the database values, an error message is displayed.

After seeing the error message, the user enters correct data and clicks next. The code behind the next button makes the error message empty and invisible and goes

to the next page. On the next page the user clicks the browser's back button. The previous page is displayed with the valid data and the error message showing.

I had expected the error message not to be displayed.

View 2 Replies

C# - Script Does Not Stop While Close The Browser Or Click Abort?

Jan 22, 2010

I wrote a webcrawler which calls a web page in a do while loop amount 3 seconds

totally there are 7000 sites... i parse the data and save it in my DB.

sometimes because the script is loading for a long time, i got a timeout in browser,

but in background i continues. I see that on my database.

Can I prevent this?.. Now it's just possible if I stop webserver.

View 2 Replies

Architecture :: Stop User From Opening A New Browser With Same Session ID?

Dec 7, 2010

Problem Statement: I have a details web page which has a unique sesssion ID generated per user. Now if a user does Ctrl + N or File > New Window and opens a new browser instance then the same session ID is genrated and user can update on both the windows differently and this leads to ambigous updates to DB. How can we stop user to open a new window or how can we detect that a new instance of the same session ID has been genrated twice so as to kill both the sessions with a user firiendly message.

View 1 Replies

Security :: Stop Browser Prompting To Save Login Details?

Nov 12, 2010

I have a VS 2008 asp.net c# application and a Login web page with a

Login Control from:-
System.Web.UI.WebControls.Login

Ive notice that some browsers (may be all) prompt to save the user login information when they first try the Login.

How can I stop this?

Ive read many solutions, one being setting the Username & Password TextBox controls to blanks.

View 6 Replies

Web Forms :: Clear Browser Cache And Stop Pages From Being Cached?

Oct 25, 2013

when i first run my applcation some time its showing the data from cache.i want to avoid it in first time .

i want to cache my all images/css/js file what is the efficient way to do it.

i have lot of images folder /js /css files.

View 1 Replies

C# - How To Stop The Browser Storing Form Data Which User Entered In Text Fields

Aug 3, 2010

I dont know whether this simple task or not, but I tried to search in google but couldn't find anything.

I've a asp.net form and user enters some data in the text boxes provided. Whenever user submits the form, browser will save that form data. I don't want this form data to be saved in browser. How can I restrict the browser saving this form data without touching the browser settings?

Application is developed using asp.net and normal text boxes are used here.

View 2 Replies

Installation :: Stop W3wp From Holding Database Connections Open After Exit

Apr 22, 2010

We have an internal ASP.Net 3.5 application that opens Pervasive SQL databases, reads the data, and then closes the connection. Unfortunately, when the user exits the application, and even when they close their browser, the w3wp process seems to be holding the PSQL database connections open, which is causing licensing issues for us. I would like the w3wp process to release the database connections once the last user has exited from the ASP.Net application. How can I get w3wp to release the connections?

Someone told me that the Powershell command, "gps w3wp | kill" will stop the w3wp process. Is there any way I can automate this, so that the process will be killed automatically when the last user exits our ASP.Net application?

View 1 Replies

Visual Studio :: How To Open Project Created By Someone Else

May 20, 2010

How to open project created by someone else in visual studio

I have copy of project created by some one and now I want to be able to open that project and work further on it.

View 1 Replies

SQL Server Won't Open DB Created By Visual Studio?

Jan 8, 2010

I've built an ASP.Net site in Visual Studio, and created the DB inside it (the .mdf file is in the APP_data folder).

Now, when I want to deploy in the customer site, I think about maintaining the DB without open Visual Studio, and by using the SQL Server Express tools (back up etc.).

I've searched how to do this, and learned that I should attach the .mdf file to sql server.

I've tried to do this and failed!

The error is: Unable to open the physical file "< .mdf >". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)

Now I have 2 options:

1. To give up and deploy the site in the current situation where the DB is an .mdf file and ASP.Net can connect to it by the SQL server express compact (in the proccess).

To extract all the data (I need to think how...) and import it to new DB, this time in SQL Server DB.

View 3 Replies

Open PPT In Web Browser?

Sep 21, 2011

Is there anyway i can open a ppt in web browser or may i can do things

Like slideshare does to view documents like ( ppt, doc ...etc )

View 5 Replies

Way To Have The Object's Key Be Dynamically Created

Nov 11, 2010

I have been experiementing with the annonymous types in C#, and am wondering if it would be possible to have a 'dynamic key' in the annonymous object.Here is what I have so far:

[Code]....

[ { "monday": true } ] what I am getting: [ { "temp": true } ]Is there a way to have the object's 'key' be dynamicly created? What I want it to be able to send the KeyValuePair's key as the object's key. Is this possible?

View 2 Replies

Get Value Of Dynamically Created Radiobuttonlist?

May 24, 2010

I'm trying to get the value of a dynamically created radiobuttonlist via javascript to call a pagemethod.

This is how I'm creating the rbl:

rbl.Attributes["onclick"] = "javascript:preview('" + rbl.ID + "','" + rbl.ClientID + "');";

And this is the javascript:

function preview(controlid, clientid)
{
var radio = document.getElementsByName(clientid);
var answer = "k";
for (var ii = 0; ii < radio.length; ii++)
{
if (radio[ii].checked)
answer = radio[ii].value;
}
PageMethods.SaveAnswer(controlid, answer);
}

The problem however is that I want to get the groupname of the radiobuttionlist so I can use getElementsByName, but i have no luck so far.

View 1 Replies

MVC :: Open URL In Browser From Controller?

Jan 24, 2010

I need to integrate a solution to keep track on number of clicks an advertisement receives from site. I am using ASP.NET mvc model with VB.NET.

My idea is to direct the url click from view to controller, update in database from controller and open/redirect the user to the Advertisement URL on new browser also from the controller.

My question is how to open a url in a new browser window from controller?.

View 2 Replies

Open Up A PDF File Within The Browser?

Apr 20, 2010

I have the following code below to open up a PDF file within the browser :

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "inline;filename=abc.pdf");
Response.WriteFile();
Response.End();

My question is, when this opens up in the browser, it takes over the whole page. Is there a way to limit the height? The reason I'm asking is, I have three menu items above the page to open up a specific pdf. So if I click on one of the links to view that pdf, the pdf show up, but the links disappear because of the PDF.

I also don't want to use iframe to populate the PDF.

View 3 Replies

Web Forms :: Open PDF In Browser Tab

Nov 8, 2012

I want to open pdf on another tab of browser on click of link button.

View 1 Replies

Web Forms :: How Open A Website Page Created By Using Parent And Child Frame

Sep 16, 2010

i create a web site using parent and child frame when we login

[URL

this page is opend but we type in address bar

[URL]

this page also open in full explorer but i want this page is not opened when we type in explorer

[URL]

View 3 Replies

Web Forms :: Stop Users Users Using The Browser Back Button And Potentially Submitting An Old Version

Mar 25, 2011

I need to stop users users using the browser back button and potentially submitting an old version of a form.

I'm storing a guid in a session variable and also writing the value to a hidden form field and then checking the session value against the hidden field value if a user does try to navigate back and submit an old form.

If the form is submitted and the user wants to complete a new copy of the form then a new guid is generated both to the session and to the hidden form field. Now, if the user decides to hit the back button a few times to get the old form and tries to submit it again, the page checks the current guid in session against the guid stored in the form field and it finds a mismatch and prevents the form being submitted.

This works as expected in Chrome and Firefox, but in IE6, when the user hits the back button to view the old form, the new guid value appears in the hidden field of the old form! This means the user can submit the old form again, which we definitely do not want.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved