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,
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
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
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
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:
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.
Please let us know if you have any other questions.
Regards,
Kalaivannan Ganesan
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
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
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