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

  • SEARCH
  • Home
  • 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 8532751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:47:12+00:00 2026-06-11T09:47:12+00:00

I have an html file in my asp.net webforms project that people can download

  • 0

I have an html file in my asp.net webforms project that people can download when clicking a button.

I would like to generate some <select> lists and append to certain parts of the html based on some database values before the file gets sent to the user. Is this possible using c#? My current download functionality:

public void DownloadOfflineAuditSheetEditor(object s, EventArgs e)
{
    Response.AppendHeader("content-disposition", "attachment; filename=thefile.html");
    Response.WriteFile(Server.MapPath("~/thefile.html"), true);
    Response.End();
}
  • 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-11T09:47:13+00:00Added an answer on June 11, 2026 at 9:47 am

    Yes – you’d have to manipulate “the file” before it gets sent to the user.

    In your method DownloadOfflineAuditSheetEditor you could have call a new method that reads the current file, gets the contents from the DB and then writes to the file or a new file, for example:

    public void GenerateRealTimeContent() 
    {
    
       var path = Server.MapPath("~/thefile.html");
       var dbContent = Database.GetContent(); // returns the <select> Options
       string[] lines = System.IO.File.ReadAllLines(path);
       StringBuilder sb = new StringBuilder();
    
       foreach (var line in lines) 
       {
         if (line == "CONTENT WHERE YOU WANT TO EDIT") 
         {
            SB.AppendLine(dbContent);
         }
    
         SB.AppendLine(line);
       }
    
      // code to write to your file
    
    }
    

    Then in your original function do:

    public void DownloadOfflineAuditSheetEditor(object s, EventArgs e)
    {
       GenerateRealTimeContent();
       Response.AppendHeader("content-disposition", "attachment; filename=thefile.html");
       Response.WriteFile(Server.MapPath("~/thefile.html"), true);
       Response.End();
    }
    

    http://msdn.microsoft.com/en-us/library/ezwyzy7b.aspx – Reading from a file

    http://msdn.microsoft.com/en-us/library/aa287548(v=vs.71).aspx – Write to a file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I am working on an ASP.net webforms project where I would like to
I have a large HTML file (In ASP.NET) that has several smaller ... tags
I have a asp.net project with a html file(Html 5). I am trying to
I have a asp.net form with 5 HTML file input controls with runat=server and
I have an HTML file and i would like to parse through it using
I have a Html Helper file for my ASP.NET MVC application. The majority of
I have a html file like following: <form action=/2811457/follow?gsid=3_5bce9b871484d3af90c89f37 method=post> <div> <a href=/2811457/follow?page=2&amp;gsid=3_5bce9b871484d3af90c89f37>next_page</a> &nbsp;<input
I have a .php file, and a .html file. Within a button click, I
I have a asp.net application, which used html templates to generate content and sends
I'm developing an ASP.Net project. I have an <asp:Table> control on my page, to

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.