I have a FreeTextBox control in my aspx page.
First, the client types the text into the FreeTextBox and click button Save
to write the text into Database (sql server 2008).
Then, in Edit function, the text is loaded from Database into FreeTextBox again for Editing.
After Editing, client clicks OK
to write the new text into Database but the new text isn't allowed be null or empty.
Take a look at my simple code:
public void btn_OK()
{
if(string.IsNullOrEmpty(FTB.Text))
Labelerror.Text="The text cannot be null or empty.";
else
{
...write new text into Database...
}
}
Building: when I clear the old text and click OK, the program passes the if
statement and does the codes inside else
statement (write new text into Database).
Try to debug, I clear the old text and let the FreeTextBox empty but the FTB.Text= "<p class=\"MsoNormal\"><br></p>"
Where is the <p class=\"MsoNormal\"><br></p>
from???
As recommended, I use HttpUtility.HtmlDecode
to decode that html tag:
string text= HttpUtility.HtmlDecode(FTB.Text);
if(string.IsNullOrEmpty(text))
But nothing change: text= "<p class=\"MsoNormal\"><br></p>"
Help!!! How can I remove that html tag to check if the FreeTextbox is null or empty.