Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:02:38+00:00 2026-06-11T14:02:38+00:00

I need a button that allows me to open any given file through ASP.NET

  • 0

I need a button that allows me to open any given file through ASP.NET C#.

Here’s what I have already.

string strArchivo = "FileNameHere";
string strExtension = Path.GetExtension(strArchivo).ToLower();

if (strExtension == ".pdf")
{
    //I open a file which is located in a folder called Archivos
    Response.Write("<script>window.open('/Archivos/" + strArchivo + "');</script>");
}

Here’s the problem, I know that this method is used to open pdf files since they are opened on the browser, and then you can either download them or print them from there.

My boss is asking me that at least I could also open WORD, EXCEL and POWERPOINT files, since those are the most common.

Is there a way that I could either open or download those kind of files (or any file if possible)??

Oh and one more thing, about the code I showed you, I’m noticing that everytime this method is used to open a file, my website suddenly switches fonts (some letters become larger in size, and other just switch to gray like color), Is it because I’m missing something in that code or how can I work around it??

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:02:39+00:00Added an answer on June 11, 2026 at 2:02 pm

    Try testing for additional file type extensions:

    string strArchivo = "FileNameHere"; 
    string strExtension = Path.GetExtension(strArchivo).ToLower(); 
    
    if (strExtension == ".pdf" || strExtension == ".docx" || strExtension == ".doc"... etc) 
    { 
        //I open a file which is located in a folder called Archivos 
        Response.Write("<script>window.open('/Archivos/" + strArchivo + "');</script>"); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a button-like control that can have a Checked property, so that when
I have a ListView that displays a link button. I need the link button
I have a hidden button on a form that I need to click in
I need a button that takes login for certain user without entering the password.
I've got a button that I need to be disabled when validation errors occur
I've got a Primefaces command button that I need to add a callback to
I need that on every page change or on some elemetents (a, input[button, submit],
I need to add functionality to the close button in my class that extends
I need a function that a user can just click a flash app button
i placed one button in a page .when click on that need to show

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.