locked
which control may be used to display rich text editor data RRS feed

  • Question

  • User1623409651 posted

    Hi all,

    I have data in letter format in rich text editor like tinymce and storing that data in database . now can any body suggest which data binding control may be use to display the data like in this forum display.

    Thanking you,

    Thursday, July 20, 2017 5:11 AM

Answers

All replies

  • User-1509636757 posted

    You can use Label control to display HTML text. But you can also use tinymce itself as readonly and remove menu, toolbar, statusbar to display the HTML content:

    <script type="text/javascript">
    tinymce.init({
        selector: "textarea",
        readonly: true,
    	mode : "textareas",
    	menubar: false,
        statusbar: false,
        toolbar: false
    
    });
    </script>
    
    <form method="post">
        <textarea name="content">test</textarea>
    </form>

    Example: http://fiddle.tinymce.com/HVfaab/1

    You can further work on CSS, to even remove the borders.

    <style>
    .mce-tinymce, .mce-edit-area { border: none!important }
    </style>

    Thursday, July 20, 2017 6:36 AM
  • User1623409651 posted

    Thanks for reply,

    Basically i have to generate letters based on stored employee data. for that purpose i have to define the letter text once and store into database using tinymce.

    Now i have two queries

    1. all letter once

    2. employee name will be from employee table

    please suggest the way . may we pass placeholders in tinymce?

    Thursday, July 20, 2017 6:48 AM
  • User-1509636757 posted

    1. all letter once

    2. employee name will be from employee table

    Use PlaceHolders (#EmployeeName# for example) and replace these PlaceHolders with actual value from database while displaying it on page.

    Thursday, July 20, 2017 6:50 AM
  • User1623409651 posted

    Thanks for quick response ,

    for display may i  need to use the data-bind control ?

    Thanks

    Thursday, July 20, 2017 6:55 AM
  • User-1509636757 posted

    for display may i  need to use the data-bind control ?

    I don't think data control is required to display HTML content by replacing PlaceHolders. I believe all you need to do is get the HTML from database, replace the PlaceHolders and display/use the updated HTML. Here is a somewhat similar kind of example that replaces the PlaceHolders and trying to use the HTML content to send email:

    //-- I am reading the html from a file, but in your case it will be from database, i guess.
    string emailBody = System.IO.File.ReadAllText(Server.MapPath("~/EmailTemplates/SubmitDetailTemplate.htm"));
    
    emailBody = emailBody.Replace("#FirstNameInputByUser#", tblEmployeeRec.FirstName);
    emailBody = emailBody.Replace("#MiddleInputByUser#", tblEmployeeRec.MiddleName);
    emailBody = emailBody.Replace("#LastNameInputByUser#", tblEmployeeRec.LastName);
    ...
    ...
    //-- now use this emailBody to display or send email. Above PlaceHolder must exist in html to replace them with database values.
    

    Thursday, July 20, 2017 7:02 AM
  • User1623409651 posted

    Thanks for reply,

    After replacing the placeholders  i have to show the all generated letters for print thatswhy i am talking about databind control or some thing similar to show the generated letter to end user.

    again thanks for your continuous support in this regard.

    Thanks

    Thursday, July 20, 2017 7:11 AM
  • User-1509636757 posted

     i have to show the all generated letters for print

    you can relate this thread: Printing the values inside the PANEL control only | The ASP.NET Forums. Alternatively, you may try using <div /> tag and set the HTML letter to div and then print the div.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 20, 2017 7:27 AM