Reputation: 161
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
Upvotes: 1
Views: 1252
Reputation: 3635
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?
Upvotes: 3
Reputation: 3726
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)
Upvotes: 1