Reputation: 7217
HTML generated string is not showing as HTML on GUI, but as plain string. I've put non-breakable spaces and <br/>
inside this string, but it doesn't show up as HTML.
Column with this problem is [Naziv izdelka]
. What am I doing wrong? Why is HTML not showing as HTML but as plain string?
Here is example.
Here is code where I generate this table (column cPROD_NME):
iQuery qPackage = db.LoadInsertSMPRPR_BASE(null, iPROD_KEY, null, "1", null, null, null, null, null, "5");
StringBuilder sb = new StringBuilder();
int counter = 1;
if(qPackage.RecordCount() > 0)
{
while(!qPackage.EOF() && counter <= 5)
{
double? decPRPR_QUA = qPackage.AsFloatN("PRPR_QUA");
string cPROD_NME1 = qPackage.AsStringN("PROD_NME1");
string basicUnit = qPackage.AsStringN("basicUnit");
sb.AppendLine($@"-  {decPRPR_QUA}x {cPROD_NME1} [{basicUnit}]<br/>");
counter++;
qPackage.Next();
}
}
cPROD_NME += "<br/>" + sb.ToString();
Upvotes: 0
Views: 481
Reputation: 1433
It's unclear from your question how the contents of your StringBuilder
gets rendered on your view. Look at the helper function Html.Raw()
which allows you to write to the view with no decoding. And check out HttpUtility.HtmlEncode()
and HttpUtility.HtmlDecode()
Encode()
: https://msdn.microsoft.com/en-us/library/73z22y6h(v=vs.110).aspx
Decode()
: https://msdn.microsoft.com/en-us/library/7c5fyk1k(v=vs.110).aspx
Raw()
: https://msdn.microsoft.com/en-us/library/gg480740(v=vs.118).aspx
Upvotes: 1