文件 Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server" Height="118px" Width="242px"></asp:TextBox>
</div>
</form>
</body>
</html>
文件 Default2.aspx.cs
using System;
using System.IO;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
StreamReader sr = File.OpenText(Server.MapPath("1.txt"));
TextBox1.Text = sr.ReadToEnd();
}
}