How to display HTML Page as in gridview c#? - html

Hi I am developing a html tag based user input, like a rich text box, which saves all the data into a database; including all the html tags.
I then am pulling this data using gridview in asp.net c#.
But when the gridview displays my data, it displays incorrectly.
For example: a user enter his name in bold in the rich textbox as such < b > Superman < /b >, to make it bold. Sadly the gridview displays ecxactly what was entered tags and all without making it bold.
Another example: To enter the name in italics:< i > Superman < /i >, Superman is being display, not in italics.
What I want is for the gridview to display like an HTML PAGE, just like the rich textbox does.
I am using to write question. <-- no idea
Can you help me please?
Thanks

when you bring the html(because that is what you are asking them to enter) back to the view, you are either going to need to transform it yourself or eval the html as is mentioned by #MikeB
alternatively if you are not using Razor try this question for some ideas:
Is there a way to insert Html into a gridview row?

You need to display the raw html. Otherwise it is html encoded to prevent people from being able to run scripts against your site.
You need to be extremely careful displaying user inputted raw html.
If you are using razor it will be something like this:
#Html.Raw(ViewBag.HtmlOutput)

Related

Create custom templates using ckeditor, tinymce or any online editor

I am not sure if the title represents what exactly I need to do, But here is the details. I am building a website using PHP that allows people to create different templates, then they should select one of them and then fill the fields to fill the placeholders. For example consider the following image
The name of the recipient could be a placeholder so some part of the template can be
Dear {recipient}
{body}
and I prepare two fields for recipient and the body and it will be replaced by the value of the corresponding field. I can do this. What I can't do is how to let the user to align the placeholders in the paper. For example there is a placeholder for the date that must be at right of the page, or any other placeholder that can be place inside the paper (same as the following image). I would like to know if ckeditor or any other editor allows me to create such template?
The structure of the template must be kept in A4 or A5 print page.
I’m having trouble understanding your question. If you're looking for templates in TinyMCE editor, I think you should try using template plugin for tinymce - there is one for wordpress. You can write your own plugin too, there was question about it.

SSRS SharePoint List outputting HTMl format for a field. How to remove HTML tags so it just shows the content

I have a microsoft sharepoint list and I am trying to output this into an SSRS report. Most fields work, however one particular field that doesnt is seen in the iamge below where it outputs HTML? How can I format this so it only displays whats in the P tag?
Thanks
Found the answer - if you click on the row you want to remove the HTML for, and right click on placeholder properties, under markup type there is something called HTML - Interpret HTML Tags as Styles.

How to save html content in mongodb via SpringBoot form

I am working on a SpringBoot based MVC application which uses mongoDB to store the data. I am using thymeleaf as the template engine. In one of the scenarios, the user needs to fill a form which is then displayed on some view.
The problem I am facing is that the user can use html tags to format the data while writing in the textArea of the form (code snippets, tabular format etc). But when I am displaying that text, the html is not being parsed and is displayed as is.
For Ex: <b>String</b> should be displayed as String but is being displayed as <b>String</b> only. When I check the source code of the page, the html tags are displayed as encoded i.e. < is showing as &lt ; etc and hence the parsing is not happening.
Can someone please help
You can output unescaped text with th:utext. From the official turorial
If we want Thymeleaf to respect our XHTML tags and not escape them, we will have to use a different attribute: th:utext (for “unescaped text”):
<p th:utext="#{home.welcome}">Welcome to our grocery store!</p>
The tutorial assumes that home.welcome is a string with html-tags:
home.welcome=Welcome to our <b>fantastic</b> grocery store!.
It goes without saying that this needs very careful validation so that only safe (whatever safe is for the particular use case) HTML is stored into the database (and no possibly malicious code like <script/> tags).

How to stop tinymce converting html tags from database

I can create my content fine using tinymce , it also uploads correctly to the database. here is an example of what stores in the database.
<p>Content goes in here</p>
When I choose to edit this it converts my p tags in the database to <p>
and then wraps the content in another set of p tags.
in source code of tinymce it looks like this
<p><p>this is a test message</p></p>
How do I stop this ?
as I just want it to render exactly as it is in the database.
I want to still store correct html tags in my database but I do not want tinymce to keep stripping/converting them.
Thanks in advance for your help.
Adam
Are you looking for somethink like that
tinymce.init({
...
entity_encoding : "raw"
});
tinymce encode the content before passing it to the server and hence the content is stored as: <p>This is text;/p> but the html tage are still passed like <p><p>This is text;/p></p>
While saving it to the database encode the values so that the html/xml tags are stored encoded. Like; Server.HtmlEncode(_propertyShopAdvertDetails.MarketingInformation);
and similarly while retrieving and displaying in the tinymce control the vaue needs to be decoded;
Server.HtmlDecode(_propertyShopAdvertDetails.MarketingInformation);
while retrieving the content and displaying it in the control, it decodes it and displays it correctly. Since it is displaying the content fine so I believe you have the right class on the control and used the correct mode for the plugin.
Now if you want to display the content in an HTML page and not inside tinymce control the you need to decode it. Something like: #Html.Raw(System.Web.HttpUtility.HtmlDecode(Model.PropertyFullDescription))

django-displaying data the way they are entered by the user

I have a models.py file where i have a textfield
models.py
class xyz(models.Models):
abc=models.TextField()
I am using html form to save the data for the abc field.
The problem is that if i enter the data in multiple lines in the form and try to display it, the whole matter is displayed in a single line.
So what is the error?
Is it in the models or what?
Thanks in advance.
The user enters a plain text, and than you are trying to show it as HTML. these are different formats.
There are a lot of possibilities, the simplest one is to let the user enter HTML and than everything will work as expected.
To do this, use some HTML editor like tinymce
Other solution is to use some markup formatting