dimanche 3 juillet 2016

show html code stored in database

I am using mvc, c# and sql. And I try to bring html code from my database ( for example , code for tables), and to show it in my view. This is my viewmodel:

viewmodel:

public string Color { get; set; }
public string body { get; set; }
public string style { get; set; }

it is my code from my controller

 entity db = new myentity();
var html = new htmlviewmodel();
html.body=db.getbody(); //gets html code for my view, for example, a table
html.style=db.getstyle(); //gets a css style for instance, mystyle

and it would be my view

this is your table:
@model.body 
<div style=@model.style> bla bla </div>

Can anyone help me to know how to store html in my database? and how to use the html in my view?

Aucun commentaire:

Enregistrer un commentaire