How to display html from the model

  1. #1

    How to display html from the model

    Hi,

    we are developing a solution to create customer invoices. The invoice is generated as an HTML document. We wish to display the HTML to the user with a button for approval.

    The model has a string field which contains the full html code of the invoice.

    public partial class InvoiceOutput
        {
            public short OutputId { get; set; }
            public int Quantity { get; set; }
            public decimal Price { get; set; }
            public string Html { get; set; }
            public System.DateTime DateCreated { get; set; }
        }
    We have tried

    X.FormPanelFor(s => s.Html)
    However, we can't get the HTML to display.

    What is the correct/best way to display a formatted HTML document?

    Thanks
    Ian
  2. #2
    How about setting the .Html property of a Panel?
    Geoffrey McGill
    Founder & CEO
  3. #3
    Hi Geoffrey,

    can you provide an example how to set the Html property of the panel from the (MVC) model. I've tried to access it from the store, without success.

    Thanks in advance
    Ian
    Last edited by ibradley; Dec 04, 2019 at 9:45 PM.
  4. #4
    Assuming your model is an InvoiceOutput class with a Html string property, you then just provide the Html reference to the .Html() property. There's really not much:

    @model InvoiceOutput
    
    @(
        Html.X().Panel()
            .Html(Model.Html)
    )
    Hope this helps!

Similar Threads

  1. Error in display data create by html Editor
    By chienthang159 in forum 1.x Help
    Replies: 1
    Last Post: Jul 03, 2014, 9:26 AM
  2. Replies: 0
    Last Post: Jul 31, 2013, 4:23 AM
  3. Replies: 1
    Last Post: Jul 30, 2013, 4:36 PM
  4. [CLOSED] making text area to display html formated text
    By SymSure in forum 2.x Premium Help
    Replies: 1
    Last Post: Sep 19, 2012, 6:07 PM
  5. [CLOSED] Html editor display
    By speedstepmem2 in forum 1.x Premium Help
    Replies: 1
    Last Post: Nov 10, 2009, 1:10 PM

Posting Permissions