open pdf file C# and asp.net [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have some customers in a gridview. When I click on the customers I can get their names in a textbox. There is also a corresponding pdf document which should also be available if the user desires.
My problem is that I need to know who to open a pdf document using C# and asp.net. I have to use a variable name as the name of pdf document, for example when the click on a button "open variable CustomerName.pdf".
I need to open a pdf file in a new window for viewing
thanks
this works
asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/customerUnit/Customer.pdf" Target="_blank">HyperLink
But I want to pass the pdf file as a variable "Customer.pdf" should be "VaribleCustmer.pdf"

I agree with #Ahmed from the comments, you shouldn't over-think this:
Simply link to the CustomerName.pdf if your using a hyperlink.
Simply redirect to the CustomerName.pdf if your using a button
But I want to pass the pdf file as a variable "Customer.pdf" should be "VaribleCustmer.pdf"
Asp Markup:
<asp:HyperLink ID="HyperLink1"
runat="server" Target="_blank">
Code behind:
var pdfFile = "Customer.pdf"; //or VaribleCustmer.pdf
HyperLink1.NavigateUrl= String.Format("~/customerUnit/{0}", pdfFile);

Related

How to capture drop-down, checkbox and radio selected text? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
This is a hard one. Need to read in plain text from Word, HTML files, and any readable content from drag-n-drop or copy-n-paste. See below for examples:
Drag-n-drop from Word or alike editor:
Copy-n-paste from browsers:
Using the suggested block I'm able to read in most text except the selected values of drop-down, checkbox and radio buttons.
var text = System.Windows.Forms.Clipboard.GetText();
Clipboard.SetText(text);
How to capture the missing selected values/text of drop-down, checkbox and radio button?
var text = System.Windows.Forms.Clipboard.GetText();
Clipboard.SetText(text);
Will turn the rich text on the clipboard into plain text.
On every machine I use I keep a batch file, calld text.bat on my path which does this to the clipboard contents, so I can press Win+R then type text and convert my clipboard contents to plain text.

reading div after javascript load [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm having problems parsing information from a forum.
Heres some examples:
Easy
Hard
It would be really easy to get the information as they are displayed in the div where id = "poe-popup-container".
The problem is that that div is only populated when the browser allows you to see the information. That can be easily reproduced by making your browser height really small and looking in the HTML code for the . However, the div will be empty, but as soon you scroll down to see the item it will change.
I'm trying to read the nodes inside the with htmlagillitypack. The problem is that, as i explained, it only has information when the browser says that you need that information.
So, when you try to download the html, the div is empty.
I've tried to download the page with the web browser too, but the same thing happens.
I'm trying to use the following code:
string page = System.Text.Encoding.UTF8.GetString(Webclient.DownloadData("http://www.pathofexile.com/forum/view-thread/966384"));
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[#id='poe-popup-container']");
MessageBox.Show(node.InnerHtml);
You're trying to do impossible. Javascript is executed in browser. HtmlAgilityPack is library just for parsing static html - it can't execute javascript.
So why don't you look into browser automation instead ? Try for example http://watin.org/

Load a second ASP.NET page into codebehind [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have something I'd like to attempt, but am unsure of the best path to accomplish it. I have a page, say default.aspx, that creates some content. I also have a second page, say input.aspx, that creates a small select box. This box is to be loaded via ajax on a chang emade on default.aspx. However, I also need this box to initial load in the codebehind of default.aspx.
Example:
1. default.aspx codebehind creates content and loads input.aspx in the codebehind
2. field changes on default.aspx and input.aspx is changed via ajax using Jquery
However, I cannot seem to find the best possible way to load a second ASP.NET page into the codebehind of the initial page. I was considering using an HttpWebRequest object, but am not sure the syntax. Any help would be appreciated.
Thanks!
At Request of #Mbeckish
What I need to happen is outlined below step-by-step
default.aspx loads with content generated from codebehind
Also in codebehind, a select box is loaded (I have this in a separate input.aspx file now. This is the step I need help with.)
default.aspx response is returned and displayed on client
user changes a form value on default.aspx
the select provided by input.aspx is reloaded from server (I currently use a JQuery ajax request to allow this)
Sounds like your second page 'input.aspx' should really be a UserControl (.ascx file), which you dynamically load (using Page.LoadControl(...)) in your default.aspx page.
What you need is to add an iframe to default1.aspx and set it's src property to be the other page
<iframe src="otherPage.aspx"></iframe>
http://www.w3schools.com/tags/tag_iframe.asp

what is the reference for "Document" in this code? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have this code for opening a PDF file and editing it's content but I don't know what the reference of "Document" in this code is . Here is my code :
//Open document
Document pdfDocument = new Document("input.pdf");
//Get particular page
Page pdfPage = (Page)pdfDocument.Pages[1];
//Create text fragment
TextFragment textFragment = new TextFragment("main text");
textFragment.Position = new Position(100, 600);
//Set text properties
textFragment.TextState.FontSize = 12;
textFragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");
textFragment.TextState.BackgroundColor=Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
textFragment.TextState.ForegroundColor=Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red);
//Create TextBuilder object
TextBuilder textBuilder = new TextBuilder(pdfPage);
//Append the text fragment to the PDF page
textBuilder.AppendText(textFragment);
//Save document
pdfDocument.Save("output.pdf");
This code works with a library called Aspose.Pdf for .NET which is a commercial product. You need to buy that library or download a trial, then add the dll that you will download as reference to your project.
I'm sure the code sample was taken from a website. Look on the products from their page if you are interesting in buying. There are also free solutions for PDF. I only used ITextSharp.

Get Image url from method [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have an image and I want to get image url with method .I found this questions on the web.But answer not quite.
Source as follows:
<img id="largeImage" src='<%#ShowLast() %>' alt="" />
cs file as follows:
public string ShowLast()
{
using (DBMLDataContext dc=new DBMLDataContext())
{
var query = (from d in dc.News
select d).Last();
return query.Photo.ToString();
}
}
Whats happening? If you are using this inside a databound control then <%# is right. If not you will want to use <%= or better yet one of the variations that encode the output.
Based on your comments it sounds like you should just use an <asp:Image> control and then set its ImageUrl property in the codebehind.
Markup:
<asp:Image runat="server" id="largeImage" GenerateEmptyAlternateText="True" />
Code Behind:
// in page load
largeImage.ImageUrl = ShowLast();
The only gotcha I can think of with this approach is if you are using the id "largeImage" in your css or somesuch. Converting it to an asp.net control means it will take control of the ID so you will need to target it through your css with a CssClass property or if you are using a modern version of .net you also have some other options to set the ID to a static id - I'll update again if this is an issue.
You can call the method like this
<img id="largeImage" src='<%= ShowLast() %>' alt="" />
if method is returning URL in string

Categories