Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
95
ASP.NET WebHtmlEditor loses its value on submit
posted

Entering text in a WebHtmlEditor control and clicking a submit button submits the form.  However, the value of WebHtmlEditor.Text is always empty, regardless of what was typed in the WebHtmlEditor.
- Add a WebHtmlEditor control to an ASPX page.
- Add a button to submit the form.
- Capture the WebHtmlEditor contents in the code-behind .cs file using WebHtmlEditor.Text
- Type text into the WebHtmlEditor and submit the form.
Placing a breakpoint on WebHtmlEditor.Text will show that the Text value is empty.
This result occurs both inside or outside of an UpdatePanel, so that is not the problem.

  • 95
    Verified Answer
    posted

    The data was being refreshed on postback, so the original value (which is blank) was being submitted.  Adding a postback check solved the problem.

    if (!Page.IsPostBack)
    {
        RefreshData()
    }