2010-12-13 23 views
1

我有一個HtmlEditor(ajax控件),我在這裏給一些內容由用戶點擊按鈕(從數據庫中獲取)修改。如何識別Html中的輸入字符

當我把內容放到一個文本框控件中時,'空格'和'輸入'就像它存儲在數據庫中一樣,但是當我使用HtmlEditor'空格'和'輸入'時,文本顯示爲純文本段。

我的代碼如下:

OdbcConnection casetype = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=testcase;User=root;Password=root;Option=3;"); 
      casetype.Open(); 

//*******to get order 
      string ordequery = "select orde from testcase.orddetpabak where fil_no=? and orderdate=?"; 
      OdbcCommand ordecmd = new OdbcCommand(ordequery, casetype); 
      ordecmd.Parameters.AddWithValue("?", HiddenField4.Value); 
      ordecmd.Parameters.AddWithValue("?", TextBox3.Text); 
      using (OdbcDataReader ordeMyReader = ordecmd.ExecuteReader()) 
      { 
       while (ordeMyReader.Read()) 
       { 
        String order = ordeMyReader["orde"].ToString(); 
       } 

      } 

string editorcontents= "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + order ; 
Editor1.Content = editorcontents; 

如果我根本就

textBox1.Text=order; 

比一切都很好,但我想在HTML編輯控制相同的輸出。我該怎麼做?

回答

3

您需要<br />代碼來替換換行符:

string editorcontents= "<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + order.Replace(Environment.NewLine, "<br />"); 
+0

或者只是''
如果是HTML(而不是XHTML) – jgauffin 2010-12-13 11:16:50