最近小舖有人提到這個問題....
其實一般在網路上找到的答案都是用"\r\n" 來取代 "vbCrLf"
但有一個更好的方法就是用c#本身就有的"Environment.NewLine"來取代vb的"vbCrLf"
小弟介紹一個範例用"Environment.NewLine"與"\r\n"都可達到vb的"vbCrLf"功能
c#範例
newline.aspx
01 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="newline.aspx.cs" Inherits="newline" %>
02
03 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
04 <html xmlns="http://www.w3.org/1999/xhtml">
05 <head id="Head1" runat="server">
06 <title>newline</title>
07 </head>
08 <body>
09 <form id="form1" runat="server">
10 <div>
11 <asp:TextBox ID="TextBox1" runat="server" Height="100px" TextMode="MultiLine" Width="300px"></asp:TextBox></div>
12 </form>
13 </body>
14 </html>
15
newline.aspx.cs
執行結果:

推到 Twitter!
推到 Plurk!
2008/3/16 23:41|
閱讀數 : 1842
|
我要推薦
|
|
文章分類 :
ASP.NET
訂閱
回覆
發表回覆
-
標題: *
-
-
姓名: *
-
-
Email: (將不會被顯示)
-
-
Url:
-
-
回覆: *
-
-