You have the complete program (ASP.net). You must have a file inside the App_Data
folder inside your ASP.net app, In this App your file name "Details.txt" which should be available inside your App_Data
folder.
You have Hidden-field and a paragraph available in your web page. When form loads, at that moment read the data from the text file and populate to the Hidden-field control. And in $(document).ready()
Jquery function populate data to paragraph from Hidden-field.
Your .aspx
page :
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="ReadFromTextFileToTextBoxWebApp._Default" %>
Welcome to ASP.NET!
and here is your code behind page :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace ReadFromTextFileToTextBoxWebApp
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var data = File.ReadAllText(Server.MapPath("~/App_Data/Details.txt"));
HiddenField1.Value = data.ToString();
}
}
}