[CLOSED] How to display html from the model

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] 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
  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 8: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!
  5. #5

    That worked!

    Thanks, that worked you can close this thread.

    However, what is the difference between using
    s=>s.html
    and
    model.html
    ?
  6. #6
    Hello @ibradley!

    How would it guess you want property s.html to go within the grid's Html property if s.html is but a string? It should at least have a .Html property in order to be mapped, something to indicate where the string should go.

    I didn't test as we already have it working in a way you could accept, but if you're really curious about it, you could try changing the InvoiceOutput.Html property from string into an object (class or anonymous) containing another Html property, or InvoiceOutput.Html.Html.

    Doesn't it make sense? Hope this helps!
    Fabrício Murta
    Developer & Support Expert

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, 8:26 AM
  2. Replies: 0
    Last Post: Jul 31, 2013, 3:23 AM
  3. Replies: 1
    Last Post: Jul 30, 2013, 3:36 PM
  4. [CLOSED] making text area to display html formated text
    By SymSure in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 19, 2012, 5:07 PM
  5. [CLOSED] Html editor display
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 10, 2009, 12:10 PM

Posting Permissions