讀寫TXT

    因爲總共就兩個頁面,一個顯示一個編輯,所以不需要搞那麼複雜,越簡單越好。從編輯頁面將排好版的內容寫入TXT,顯示頁面再從TXT讀取出來顯示。

 

編輯頁面使用的是百度富文本編輯器

前臺:

   <textarea name="uecontent" id="myEditor" style="height:200px;width:650px">請在這裏填寫內容</textarea>
<script type="text/javascript">   
 var editor = new UE.ui.Editor();
    editor.render("myEditor");  
 </script>

後臺:

     System.IO.File.WriteAllText(Server.MapPath("") + "/2.txt", Request.Form["uecontent"]);

 

顯示頁面:

定義一個DIV,在後臺讀入TXT內容

    div1.InnerHtml File.ReadAllText(Server.MapPath("") + "/2.txt");

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章