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)
Related
I have an ASP.net 4.5 text box with 5 rows. When I save the below data to my table it does not take in consideration that there are line breaks.
Example:
Hello my name is Mike!
How are you?
Please can you help?
When saving this data to my table it of course save it like this below and it will be displayed like this again if I populate my website with this value.
Hello my name is Mike!How are you?Please can you help?
But I want it to be displayed with the line breaks as the way it was written in the first place.
The thing is, I do not want to make use of a custom form item because then the user will be able to copy and paste all html from another website in and I do not want that.
Any idea how this can be done without using a plugin such as below where the user will be able to copy and paste data into?
To populate your text box from the database try;
TextBox1.Text = someText.Replace("\r\n", Environment.NewLine)
For Label
Label1.Text = someText.Replace("\r\n", <br />)
Alternatively you could save the data to your database with the
someText = TextBox1.Text.Replace("\r\n", "<br />")
Although this approach may not be appropriate if the database is also used elsewhere.
I have a word template which has a content control placeholder to hold rich text data. The data comes from a sharepoint list (rich text field) and may also include tables in it.
On checking the data from sharepoint list I found it returns me a HTML formatted data. I wish to place this data in the content placeholder with proper formatting.
For example if the data returned is HTML table ( format) I want a table to be created with data populated. Is there any method available to place the data in content control.
I found that third party tool converter at http://html2openxml.codeplex.com/ which is available for conversion, however this appends data to MainDocumentPart not to content control.
Please guide. Thanks in advance.
You could try to use WordDocGenerator, which uses content controls. Then combine it with html2openxml, as discussed here. However, I find the formatting in some cases becomes terrible after adding the html content into your content control--one example is when inserting lists, the bullet points goes out of view when you open the document. I have not tried adding a whole table into a content control.
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
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'm storing my HTML in a database so the page loads the HTML data from the database. I use ViewData in my ASPX page in order to populate the page. The HTML is stored in a NVARCHAR(MAX) column and it's working great for small pages. The problem I'm having is when the HTML is large. It populates 2 thirds of the HTML data but loses the last third. Is there a limit to ViewData?
There is no limit on view data size as far as I am aware of, certainly view data of many megabytes is possible and that should be enough to contain the HTML of even the enormous page.
How much data are you talking about? Are you actually storing the viewdata in the database as part of the page HTML? This feels like a bad idea as the view data of the page should be generated by the asp.net runtime.
Based on the comment "12.0Kb of data." I would assume your problem lies else where.
Check if the data is there before you load it to the view data.
Not sure how you rendering your viewdata. But if you store html file in database table, I am sure you have a column holding FileType. You could implement an actionlink to open an html file using FileContentResult type method. Assuming you have a table name 'HtmlPage', doc and docType as columns.
public FileContentResult GetHtmlFile(int id)
{
HtmlPage htmlPage = _repository.GetPrepAttachmentByID(attachmentID);
return File(htmlPage.doc.ToArray(), htmlPage.docType);
}
Hope this helps...