Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 8th, 2004, 02:33 AM
Registered User
 
Join Date: Feb 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default question to chinese encoding

First:I use EditFile.aspx to edit SiteFooter.ascx. I click Save_Click Button to save SiteFooter.ascx after add chinese words.
Second:Footer of web display chaos encoding when I visit web
 
Old October 8th, 2004, 04:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Does the browser have all the right language packs, and what was your specific error?
 
Old October 8th, 2004, 07:48 PM
Registered User
 
Join Date: Feb 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My answer:
EditFile.aspx.cs:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;


namespace Wrox.WebModules.FileManager.Web
{
   public class EditFile : System.Web.UI.Page
   {
      protected System.Web.UI.WebControls.Label StatusMessage;
      protected System.Web.UI.WebControls.TextBox SaveAsPath;
      protected System.Web.UI.WebControls.TextBox FileContent;
      protected System.Web.UI.WebControls.Button Save;
      protected System.Web.UI.WebControls.Table Table1;
      protected System.Web.UI.WebControls.Button Back;

      private void Page_Load(object sender, EventArgs e)
      {
         if (!IsPostBack)
         {
            string filePath = Request.Params["File"];
            if (filePath != null)
            {
               if (Request.Params["CreateFile"] == null || Request.Params["CreateFile"]=="false")
               {

                  try
                  {
                     StreamReader sr = new StreamReader (File.Open(Server.MapPath(filePath), FileMode.Open),System.Text.Encoding.GetEncoding("g b2312"));
                     FileContent.Text = sr.ReadToEnd();
                     sr.Close();
                  }
                  catch (Exception exc)
                  {
                     StatusMessage.Text = exc.Message;
                     StatusMessage.Visible = true;
                  }
               }
               SaveAsPath.Text = filePath;
            }
         }
      }

      protected void Back_Click(object sender, EventArgs e)
      {
         string filePath = Request.Params["File"];
         if (filePath != null && filePath != "/")
         {
            int lastSlashIndex = filePath.LastIndexOf("/");
            string folderPath = filePath.Substring(0, lastSlashIndex+1);
            Response.Redirect("BrowseFiles.aspx?Folder=" + folderPath);
         }
         else
            Response.Redirect("BrowseFiles.aspx");
      }

      protected void Save_Click(object sender, EventArgs e)
      {
         try
         {
            string filePath = SaveAsPath.Text;
            if (!filePath.StartsWith("/")) filePath = "/" + filePath;
            StreamWriter sw = new StreamWriter(Server.MapPath(filePath),false,System .Text.Encoding.GetEncoding("gb2312"));
            sw.Write(FileContent.Text);
            sw.Close();
            StatusMessage.Text = "Îļþ³É¹¦±£´æ";
         }
         catch (Exception exc)
         {
            StatusMessage.Text = exc.Message;;
         }
         StatusMessage.Visible = true;
      }


      #region Web Form Designer generated code
      override protected void OnInit(EventArgs e)
      {

         base.OnInit(e);
         InitializeComponent();
      }

      private void InitializeComponent()
      {
         this.Load += new System.EventHandler(this.Page_Load);

      }
      #endregion
   }
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chinese characters rajanikrishna ASP.NET 1.0 and 1.1 Basics 1 April 25th, 2006 10:25 PM
I'm chinese ChinaWolf C# 3 January 23rd, 2006 04:32 AM
i'm chinese wsaspx General .NET 1 April 6th, 2005 07:04 AM
why I can't use Chinese words? cash JSP Basics 4 February 19th, 2004 10:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.