我的 aspx 页面中有一个 FreeTextBox 控件。
首先,客户端将文本输入到 FreeTextBox 并单击按钮Save
将文本写入数据库(sql server 2008)。
然后,在编辑功能中,文本再次从数据库加载到 FreeTextBox 进行编辑。
编辑后,客户端单击OK
将新文本写入数据库,但新文本不允许为空或为空。
看看我的简单代码:
public void btn_OK()
{
if(string.IsNullOrEmpty(FTB.Text))
Labelerror.Text="The text cannot be null or empty.";
else
{
...write new text into Database...
}
}
构建:当我清除旧文本并单击确定时,程序通过if
语句并执行语句内部的代码else
(将新文本写入数据库)。
尝试调试,我清除旧文本并让 FreeTextBox 为空,但FTB.Text= "<p class=\"MsoNormal\"><br></p>"
哪里来的<p class=\"MsoNormal\"><br></p>
???
按照建议,我HttpUtility.HtmlDecode
用来解码该 html 标记:
string text= HttpUtility.HtmlDecode(FTB.Text);
if(string.IsNullOrEmpty(text))
但没有任何改变:text= "<p class=\"MsoNormal\"><br></p>"
帮助!!!如何删除该 html 标记以检查 FreeTextbox 是否为空或为空。