学导网 >> it000 >> 程序开发000
VS2005控件的问题解决办法
www.xuedao.net  2007-10-9 23:19:00 互联网

  1、取HTML代码出现乱码

  最近升级了一个C/S程序,升级后mshtml没有办法升级,后来看到.net2.0中有WebBrowser控件,但取DocumentText属性获取的页面内容时出现了乱码。通过查找网上资料,试了一下使用以下的方式可以实现需要的内容。  

  System.IO.StreamReader sr = new System.IO.StreamReader(this.webBrowser1.DocumentStream, System.Text.Encoding.GetEncoding(this.webBrowser1.Document.Encoding));

  string sHtml = sr.ReadToEnd();   

  2、让界面可以进行编辑的设置,不需要进行修改HTML页面。

  private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

   {
   webBrowser1.Document.Body.SetAttribute("contenteditable", "true");

   }

评论】 【关闭
相关新闻
Google提供广告