如何识别Html中的输入字符

时间:2010-12-13 11:02:34

标签: c# asp.net

我有一个HtmlEditor(ajax控件),我在其中提供了一些内容,用户可以通过单击按钮(从数据库中获取)进行修改。

当我将内容提取到文本框控件中时,'spaces'和'enter'来源于它存储在数据库中但是当我使用HtmlEditor'spaces'并且'enter'没有来时,文本显示为一个简单的段落。

我的代码如下:

 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; 

比一切都好,但我想在HtmlEditor控件中输出相同的输出。我该怎么办?

1 个答案:

答案 0 :(得分: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 />");