I have a webform where users are submitting articles that contain bold text, italics text, links, images, etc. It is being stored into nvarchar(MAX) data type.
I am able to pull the information in the same format as it was submitted on a web site (ASP.NET & C#), this is how I do that:
ASP.NET
C#
//inserting data into DB
//getting data from DB
//assigning text I got to div
body.InnerHtml = rdr.GetSqlString(rdr.GetOrdinal("Body"));
My problem is, that the article being submitted into the DB is being submitted in this type of format:
This is bold text. This is italics text. This is normal text. This is a link
Basically it is being submitted in markup - which is fine, but I have one problem. I am trying to pull this information into a TextBlock inside of my Windows 10 application (Universal Web Application), but it is coming in as HTML and TextBlock is XAML and I feel like it is not going to mesh well...
This is my XAML:
RelativePanel.Below="myViews"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
LineHeight="24"
TextWrapping="Wrap"
Foreground="Black"
Margin="0,20,0,20"/>
C#
myBody.Text = retrievedHTMLBody;
My question is, is how can I display the information (same format that it was submitted in on the web form) in the TextBlock the same way that it is displaying in my DIV? I do not have a problem pulling the data in, but it is setting the textblock text to the format(bold, italics, links, etc.) the same way I am able to set it in my DIV that is throwing me for a loop...
Talk1:
You're looking for RichTextBox/Block. Might give a peek at something like this before you go too far down the rabbit hole. There's others also but I don't remember any of them, haven't done this in some time.
Talk2:
What is the easiest way to plug that line of markup I included into the RichTextBlock to see if it is interpreting it correctly?
Talk3:
And that way looks really extensive... This has had to of been done before....
Talk4:
. Ended up finding a solution, thank you for your input again
Solutions1
I ended up finding a solution. It is to use a Webview and bind the HTML to it using NavigateToString
XAML
C#
string htmContent = @"your html goes here";
myWebView.NavigateToString(htmContent);