I have text stored in a column of a table within my database, with html tags .
Example :
<table><tr><td> hello </td></tr></table>
I am binding the text to the website and it works perfectly. It gets displayed as
hello
on the website.
Now I would like to create a rdlc report and am binding the same dataset to the report.
But I see :
<table><tr><td> hello </td></tr></table>
on the report instead of
hello
I think I understand why this is happenning , because the rdlc file cannot render html. But is there a way
that I can see "hello" on the website. ? Please let me know if you know of any other way to do it .
you can render using HTML tags in RDL as follows :
Left click the field you want to display so that the <Expr> tag is highlighted
Right click the highlighted <Expr> tag and choose Placeholder Properties...
On the General tab, select the HTML- Interpret HTML tags as style radio button
Related
I have a problem to properly display an html text from database in pdf document which is generated with iTextSharp. I have a text editor in my project and my text is written to the database in this format (example)
<i><b>Hello World</b></i><br><p>What a <font color="#330022"> wonderful day!</p>
When I pass this text to the pdf document is displayed with the tags. I don't know how to get rid of them and actually pass the bold and italic text or the color. I have found only a solution for the <br> tag like this
pdf.PreviewText = get.Rows[0]["text"].ToString();
previewText = previewText.Replace("<br>", "\n\r");
for the <b> tag I have tried previewText = previewText.Replace("<b>", ""\x1B|"); but it did not work for me. If anyone has an idea how can I replace these tags with escape characters which would work in c# I would be very grateful.
i have problem in showing my data field that already in html code inside sql. need to show it on asp.net mvc.
below is the command of html in asp.net which i already add html as fieldtype so when it read html or textbox it will show the page in html format. but now for table, i cant properly show the exact table, but only the code.
enter image description here
the sqldata field action details in html table
enter image description here
this is the output, which is not show the exact table
enter image description here
help me out!
#Htm.Raw()
when you want to render html code stored in sql first you need html tag in ef to actually be able to save it from user end then you are subject of milion of hacking attempt which btw all of them fails and then when you want to reder html what you do is just render it with razor which is #Html.Raw(_yourContext.YourTable.FirstOrDefault(q=>q.yourPK == yourVariable).yourHtmlField)
So, I have the rich text box editor from Bootstrap-Wysiwyg.
If the textbox contains:
This is a bold statement.
Then my DB will save the text as:
(using a hidden tab where I insert the editor.html())
<b>This is a bold statement.<b>
If I save the file again, the RTF will convert it to:
<b>This is a bold statement.<b>
When I put the this text back into the editor using a Model.Value, it does not convert it to rich text but instead keeps the text as though it were a string and states it exactly as it is saved in the DB.
How can I convert the text in my model to show up in the rich text editors format?
I've been searching the net quite a bit, and most functionality refers to files. This is a new subject to me, so any insight is appreciated on how to fix this. (Editing text without formatting is obnoxious!) Thanks in advance!
Just in case someone else gets stuck, I was able to resolve this issue by doing the following:
I created a hidden div (which I populate first with my Model):
<textarea style="display: none;" id="editorCopy" name="body">#Model.Body</textarea>
and left my editor div empty:
<div id="editor" contenteditable="true">
</div>
and in my JQuery:
I set my editors text to my hidden divs value, and on submit, I replace the hidden div with my editor text:
$('#editor').html($('#editorCopy').val());
$('#postSubmit').click(function () {
$('#editorCopy').val($('#editor').html());
});
This allowed my rich text to show on edit. There might be a better solution, but at least this works! :]
Let me explain in detail
There is textarea in form.
On submitting form,the text of textarea get stored in database.
While display those texts from database I want to execute basic html code like <b><i><u>...etc
For example:-If user entered "<b>hello</b>" in textarea.Then this word "hello" will display in bold letters.
Use #Html.Raw( [your HTML code from the database] ) in your View.
In your Razor-file:
<b>#myHtmlFromTheDatabase</b>
I want to insert html tag to a Database as a String and retrieve it back. after retrieved it ,I want to bind it in Grid.
as a example
String word = "<h1>This is Heading </h1> \n <h2>This is body</h2> \t This is after tab";
after I bind to the grid it should be
This is Heading(in a big font size)
This is body(in small font) - (tab space) This after tab
However this way is not working. It shows
<h1>This is Heading </h1> \n <h2>This is body</h2> \t This is after tab
word instead of applying real HTML behavior. I tryout with '\' special character removal but it remain same result.
Please help me.
Exactly which control are you using? Most of them will escape html like that for you, and to get it to be written 'as-is' you have to set a property.
If you're using GridView, then you can set the HtmlEncode on your BoundColumn to false.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode.aspx
If you're using AutoGenerateColumns, see this SO thread: Prevent HTML encoding in auto-generated GridView columns
Saving into DB is not a problem, you can save directly the string into DB,But when displaying on UI you must use HttpUyility.HtmlEncode(), else it will invite Javascript Hacking.
But if you are entering data from WebPage, make sure Input Validations are turned off Else you will get XSS script attack error.
you can bind your text in literal control it will represent the actual HTML formatted text.
like :
ltrlMsg.Text="<div class=\"Message Success\"> Your Message has been sent successfully! </div>"
or you can bind in you grid too.