Category Archives: PDF

How to implement website internal search in asp.net2.0

Hi Friends,

I did lot of R & D to implement website internal search in

I have found a good article in code project (

It has some limitations

  • Search with special characters is not working.
  • Pdf and word documents are not searching.
  • Not able to high light the searched text.
  • If I am implementing this in master page then child title is not displayed in result page.


I need to implement search result should be like this

In description the search text must be highlighted.

Note: I need to implement this with coding not any 3rd party tool (I know lots of 3rd party website which do free hosting but they will post there adds and logo).

Please suggested and provide me some good links.



Mohammed Farooq

Hey Great man,

just go to iis server ,i mean Management Console and Check whether your system has Index Server or Not,no prob if it is not there,you can just install it in one shot

next  go through these steps


shabir hakim


Thanks for the reply shabir hakim!!

I am not using any database to implement website internal search.

As I found the above code project link is usefull, so I need to solve problems (mentioned above) by implementing same link.

I found the links you supplied are not usefull to me.

Need help!



Mohammed Farooq

Any one!



Mohammed Farooq


Well it depends how you are managing your site content. I recomend to have all your site content mapped to some tag based architecture. so that search would internally be tag based . The search algo would need to consider lot of factors before displaying the appropraite matches, which i can elobrate upon but before that i would like you to explain more on the architecure of the site.

Now regarding highlighting the search text , i belive should not be a big deal , There are lot of algo's available for this.


Thanks for the reply Zubair!

Can you please explain me "architecure of the site"

Also can you please let me what are the algo's available?



Mohammed Farooq


I didn't  even suggest  to use database.I said just use Index Server for it.


[RESOLVED] Using a file upload and display the contents of the file to a textbox

Hi guys

I am using a file control to get browse and get a file. I need to display the contents of the file to a text box. Can any one help me in this.. My asp file looks like this

<asp:FileUpload ID="FileUpload1" runat="server" />

    <br />

    <br />

    <asp:TextBox ID="TextBox1" runat="server" Height="126px" TextMode="MultiLine" 


Do send a code of this

Thanks in advance..

What all file extensions are you allowing to be uploaded?

I need .doc, .pdf, .txt only text content files..

Thanks in advance


Samual Krish

I need to display the contents of the file to a text box.

According to your description ,I would like to suggest you to check the sample below:

1.Code in page(.aspx):


<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server"
            Text="UpLoad" onclick="Button1_Click" />
            Content:<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"
            Height="177px" Width="400px"></asp:TextBox>

2.Code in page(.cs):


  protected void Button1_Click(object sender, EventArgs e)
        // Please change the value of path which used to store the file.
        string path = AppDomain.CurrentDomain.BaseDirectory + "UploadFiles\\" + this.FileUpload1.FileName;
        this.TextBox1.Text = ShowContent(path);
    public string ShowContent(string path)
        string strInput = "";
        string GetStream = "";

        if (File.Exists(path))
            StreamReader sr = new StreamReader(path, UnicodeEncoding.GetEncoding("UTF-8"));
            strInput = sr.ReadLine();
            while (strInput != null)
                GetStream += strInput;
                strInput = sr.ReadLine();
            Response.Write("file does not exist!");
        return GetStream;

Please do not forget the reference namespace:

using System.IO;
using System.Text;

If you use VB.NET language ,you can use this site to convert the C# code above to VB.NET language.

Hope it can help you.

Thanks for your reply.. I was expecting this only.. Thanks a lot.. Cheers

[RESOLVED] converting html to pdf

hi i got this requirement to do using there is a page on server which is html with borders,text and tables.

i have to convert it to pdf onclick of button. this is not but please help.

Please see the links

Hi ogsim07,

HOW TO: Generate PDF Output On-the-fly


Solution 1: Use an open-source .NET PDF library. Sample list:

Solution 2: Use a commercial .NET PDF library. Sample list:

Solution 3: Use activePDF WebGrabber to convert any URL output to PDF on-the-fly.

Solution 4: Use a report generator like Crystal Reports or SQL Server Reporting Services to render to PDF.

Please check the following link: 

More tutorials on ITexTSharp -


[RESOLVED] Converting aspx page into pdf and then emailing the converted pdf



I am looking for any lib , or any solution. What I want to do is to email the generated results with some images on the website which for instance is something like results.aspx,

I have got an email button for the clients so that they can email themselves the result page in a pdf format.

Is there any way of doing, any help or tutorials will be highly appreciated.



I use iTextSharp library, which is pretty good. I use it to export GridView to PDF, but I believe you can use it to recreate the Results page.

I am using aspPDf which is quite easy and handy, nd it works out or me though, anyone looking for to pdf conversion should check

[RESOLVED] IE6 Unknown FileTypes for .xls and .rtf when using ContentType and Content-Disposition

I have an .aspx page, and I am trying to give users options to download the page in multiple formats, but both Excel and RichText are giving Unknown File Types in IE6 although they work fine in FF.


On the initial page, when the user clicks "Download," they receive a pop-up asking for a file type selection. (click a Hyperlinked Image)

Clicking the hyperlink will open a new window with a QueryString value specifying which file type they would like

The new window regenerates the content formatted for downloading, sets the response headers, etc, and the page asks if they would like to Open or Save the file.

Here is the relevant code for creating the files:

                        Response.Buffer = true;
                        string strExtension = ".doc";
                        string strContentType = "application/msword";
                        if (Request.QueryString["FileType"] != null)
                            switch (Request.QueryString["FileType"].ToString().ToLower())
                                case "word":
                                    strContentType = "application/msword";
                                    strExtension = ".doc";
                                case "html":
                                    strContentType = "text/html";
                                    strExtension = ".htm";
                                case "excel":
                                    strContentType = "application/ms-excel";
                                    strExtension = ".xls";
                                case "text":
                                    strContentType = "text/richtext";
                                    strExtension = ".doc";
                                case "pdf":
                                    strContentType = "application/pdf";
                                    strExtension = ".pdf";
                        Response.ContentType = strContentType;
                        Response.AddHeader("Content-Disposition", "attachment;filename=Extension_Form_" + strFormId + "_" + DateTime.Today.ToString().Replace(" 12:00:00 AM", "") + strExtension);
                        StringWriter stringWriter = new StringWriter();
                        HtmlTextWriter writer = new HtmlTextWriter(stringWriter);


PDF does not yet work, but I'm coming back to that later...

Word and HTML both work fine cross-browser

Excel and RichText in IE6 give the following dialog:

Do you want to open or save this file?

Name: WordViewer (the name of my page)

Type: HTML Document, 54.1 KB

From: localhost


If I choose to save the file it always saves the file with an .htm extension... if I choose to open it, it opens in the browser.

I have stepped through the code, and the correct case is being called, and the correct filename and type are being assigned.

Any ideas why this isn't working?


If it helps, I am able to successfully export Excel files from a different page using the following code, but that is just exporting a simple datatable; this form has much more going on and cannot be bound directly to a GridView control.  I tried changing "attachment" to "inline" in the code above as per the code below, but that did not help

                    Response.ContentType = "application/ms-excel";
                    Response.AddHeader("Content-Disposition", "inline;filename=export.xls");
                    dg1.DataSource = dt;

Thank you!!

Try with Application/Octet-Stream...


Thank you for the reply... the ContentType actually didn't seem to have an effect, but I did find the solution...

The filenames I was creating looked like: "Extension_Form_12345_02/25/2001.xls"

I removed the date from the filename, and now it works in IE6.


So apparently it understands that file name as long as it's a Word or HTML file, but it doesn't know what to do if it's an Excel or RichText file... all formats are working now...