石头的博客

关注flash,flex,asp,php的相关项目开发

« PHP不缓存用flash开发的iphone应用程序可以观看fms4做的在线视频 »

asp.net读取txt文本文件内容

[ At 2011-3-24 By stone   0 comments ]

文件 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();
    }
}

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Walle Build 100427 Code detection by Codefense

@2010 stonemx.com