drupal stats

Load a txt file into TextBox

July 1st, 2011 TextBox 0 Comments


Load a txt file into TextBox thumb Load a txt file into TextBox

Using File.ReadAllText() to read text file content

TextBox1.Text = System.IO.File.ReadAllText(Server.MapPath("Forum Rules.txt"));

 

Complete Source Code

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>    

        Forum Rules</div>

    <asp:TextBox ID="TextBox1" runat="server" Rows="7" TextMode="MultiLine" 

        Width="500px"></asp:TextBox>

    <br />

    <asp:CheckBox ID="CheckBox1" runat="server" 

        Text="I have read, and agree to abide by the Dotneter.com rules. " />

    <br />

    <br />

    <asp:Button ID="Button1" runat="server" Text="Complete Registration" />

    </form>

</body>

</html>

 

Default.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class _Default : System.Web.UI.Page 

{

    protected void Page_Load(object sender, EventArgs e)

    {

        TextBox1.Text = System.IO.File.ReadAllText(Server.MapPath("Forum Rules.txt"));

    }

}

Tags: importando txt c# dot net formulario, c# textbox load from file, how to open content of a file to textbox in c#, c# read text file into textbox, getting a textbox data from text file javascript, c# read text file to textbox, how to load text from text file to textbox in c#, read text file into textbox c#, c# textbox to file, linq read file with file readalltext

Related posts:

  1. Clear TextBox on Focus in ASP.NET
  2. Clear TextBox Using Javascript
  3. Read Text File C#

No Comments