Edit HTML Text Field

I follow the KB " How to implement HtmlText property for WPF RichTextBox (SfRichTextBoxAdv) Control? | Syncfusion KB" to implement the sfRichTextBoxAdvExtensionExtension for editing a text field with HTML tags.  The content is retrieved from database table instead of a file and the updated HTML text will save back to database table.


I found there is a problem if I set the FormatType to Html in line 73 and 102, I received a NullReferenceException but there is no errors if FormatType is Txt but the text box cannot parse the HTML tags in the content.  


I'm using the SyncFusion 20.2.0.40 Nuget package with Community License.  Could anyone can help to solve the problem?


Many thanks,


8 Replies 1 reply marked as answer

KG Kalaivannan Ganesan Syncfusion Team August 3, 2022 03:10 AM UTC

Hi Wilson,

We are working on reproducing the reported issue with the provided information, we will update you with further details on 4th August 2022.

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan



KG Kalaivannan Ganesan Syncfusion Team August 5, 2022 04:04 AM UTC

Hi Wilson,

We are working with a high priority on reproducing the reported issue with the provided information, In the meantime please share with us the sample application to reproduce the issue from our side because it will help us to provide you with an appropriate solution at the earliest

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan



KG Kalaivannan Ganesan Syncfusion Team August 9, 2022 04:43 AM UTC

Hi Wilson,

We have followed the mentioned KB and where we retrieved the content from the HTML file, and modified and saved text, the reported issue is not reproduced. At the meantime, we are trying to load the content from the database table.

Can you please share with us the sample application to reproduce the reported issue from our side because it will help us to provide us with the appropriate solution at the earliest

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan



WI Wilson August 9, 2022 05:44 AM UTC

Attached is the Class copied from " How to implement HtmlText property for WPF RichTextBox (SfRichTextBoxAdv) Control? | Syncfusion KB" but when there is an error "NullReferenceException".


The 7z file contains 3 threes:

  •  "ItedEditPage.xaml" is the WPF Page Content file which the modified RichTextBox is used in line# 70.
  • "SfRuchTextBoxAdvExtension.cs" is the class file of modified RichTextEdit component.
  • "nullReferenceException.png" is the Runtime Exception Error shown in Visual Studio 2022 17.3.0 Preview 6.

Also, since the application support multiple language.  the text content will include English, Chinese and Japanese characters with UTF8 encoding.

Thanks, 




Attachment: class_file_dbc4bb13.7z


KG Kalaivannan Ganesan Syncfusion Team August 10, 2022 12:20 PM UTC

Hi Wilson,

From the shared information we found that extension class is proper but from the shared image we doubt that NullReferenceException is due to loading an improper HTML file. (I.e) if the HTML file contains improper tags, there may be chances of throwing a mentioned NullReferenceException

We have also created the sample application using the KB link where HTML files with proper tags are loaded properly, and HTML files with improper tags are thrown NullReferenceException which can be downloaded below

Please share with us the htmlText which passed at line no: 90. because it will help us to validate the reported issue and provide you with an appropriate solution at the earliest.

Graphical user interface, text, application, email

Description automatically generated


Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan


Attachment: RTE_HTML_1f529b98.zip


WI Wilson August 11, 2022 01:46 AM UTC

Hi Kalaivannan,


I uploaded some screen caps here and found that the errors may come from multiple <p></p> tags.  If the text contains more than one <p></p> text, the error raised.  However if the text contains only one <p></p> tag, it can displayed without error.   And the list tags "<ul>", "<ol>" and "<li>" are also raised errors.


Also, I found that some tag, eg. "<br/>", is not recognized and displayed as normal text (please refer "problem 1.png") 


Thanks,

Wilson


Attachment: Error_HTMLs_214abdfb.7z


KG Kalaivannan Ganesan Syncfusion Team August 11, 2022 07:38 AM UTC

Hi Wilson,

When the HTML is loaded without “<html> and <body>” tags NullReferenceException will be thrown. As the shared HTML contains only the content tags and they are not maintained inside the <Html> and <body> exception thrown.

To cover this issue, we suggest you maintain content tags between the <html> and <body> tags. We have also created a sample application to demonstrate the same with the shared set of HTML which can be downloaded below

Please let us know if you have any other questions.

Regards,
Kalaivannan Ganesan


Attachment: RTE_HTML_e1bc26c5.zip

Marked as answer

WI Wilson August 11, 2022 08:25 AM UTC

Hi Kalaivannan,


I put my content inside the <html><body> tags the error was disappeared.  I think my problem has been solved that most of the html tags we used has been test without errors.  I will try more to determine which html tags are unsupported then we will prevent to use those unsupported tags.


Thanks a lot!

Wilson


Loader.
Up arrow icon