我先贴出我的代码来吧。我的代码如下:(如果没有更好的解决方案的话,我不会给分的哦)这个代码的缺点是如果将内容放入表格里面不好控制,我还没有想好,大家帮忙啊!
<%@ Page Language="vb" %>
<%@ import Namespace="System.IO" %>
<script runat="server"> Sub SendButton_Click ( sender as Object, e as EventArgs )
Dim output1 As TextWriter = File.AppendText(Server.MapPath("STORY.txt") )
Dim line As String
line = NextLine.text
output1.WriteLine(line)
output1.Close()
end sub
Sub Page_Load(Sender As Object, E As EventArgs)
Dim input1 As TextReader = File.OpenText(Server.MapPath("STORY.txt"))
Dim line As String
line = input1.ReadLine()
While Not (line Is Nothing)
Response.Write ("<br>" & line )
line = input1.ReadLine()
End While
input1.Close()
end sub</script>
<html>
<head>
<title>在线故事接龙</title>
</head>
<body bgcolor="green">
<center>
<h2>在线故事接龙
</h2>
</center>
<hr />
<h3>请输入故事的新行
</h3>
<form action="story.aspx" method="post" runat="server">
<asp:textbox id="NextLine" runat="server" size="70" TextMode="MultiLine" Columns="50"></asp:textbox>
<asp:button id="Write" onclick="SendButton_Click" runat="server" Text="添加"></asp:button>
</form>
</body>
</html>
小东西,大家见效了!
<%@ Page Language="vb" %>
<%@ import Namespace="System.IO" %>
<script runat="server"> Sub SendButton_Click ( sender as Object, e as EventArgs )
Dim output1 As TextWriter = File.AppendText(Server.MapPath("STORY.txt") )
Dim line As String
line = NextLine.text
output1.WriteLine(line)
output1.Close()
end sub
Sub Page_Load(Sender As Object, E As EventArgs)
Dim input1 As TextReader = File.OpenText(Server.MapPath("STORY.txt"))
Dim line As String
line = input1.ReadLine()
While Not (line Is Nothing)
Response.Write ("<br>" & line )
line = input1.ReadLine()
End While
input1.Close()
end sub</script>
<html>
<head>
<title>在线故事接龙</title>
</head>
<body bgcolor="green">
<center>
<h2>在线故事接龙
</h2>
</center>
<hr />
<h3>请输入故事的新行
</h3>
<form action="story.aspx" method="post" runat="server">
<asp:textbox id="NextLine" runat="server" size="70" TextMode="MultiLine" Columns="50"></asp:textbox>
<asp:button id="Write" onclick="SendButton_Click" runat="server" Text="添加"></asp:button>
</form>
</body>
</html>
小东西,大家见效了!
But thank you all the same.
<%@ Page Language="vb" %>
<%@ import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim input1 As TextReader = File.OpenText(Server.MapPath("STORY.txt"))
Dim line As String
line = input1.ReadLine()
While Not (line Is Nothing) Response.Write ("<br>" & line ) line = input1.ReadLine()
End While
input1.Close()
end sub</script>
<html>
<head>
<title>读取文本文件按照其原有格式换行</title>
</head>
<body bgcolor="green"></body>
</html>