HtmlEncode() public static method

public static HtmlEncode ( object value ) : string
value object
return string
Example #1
0
        public void FillBlogEntry(product p)
        {
            // init values for activity message
            productid   = p.id;
            productname = p.title;
            subdomainid = p.subdomainid;
            producturl  = p.ToProductUrl();

            blogEntry.Title.Text = productname;
            blogEntry.Content    = new AtomContent();
            var productpage =
                hostName.ToDomainUrl(p.ToProductUrl());
            StringBuilder sb = new StringBuilder();

            sb.Append("<div xmlns='http://www.w3.org/1999/xhtml'>");
            sb.AppendFormat("<h3><a target='_blank' href='{0}'>{1}</a></h3>", productpage,
                            HttpUtility.HtmlEncode(productname));

            if (p.sellingPrice.HasValue)
            {
                var currency = p.MASTERsubdomain.currency.ToCurrency();

                var sellingPrice = p.tax.HasValue
                                           ? (p.sellingPrice.Value * (p.tax.Value / 100 + 1)).ToString("n" +
                                                                                                       currency.
                                                                                                       decimalCount)
                                           : p.sellingPrice.Value.ToString("n" + currency.decimalCount);

                if (p.specialPrice.HasValue)
                {
                    // if has special price then original (strike-through) + special price
                    var specialPrice = p.tax.HasValue
                                           ? (p.specialPrice.Value * (p.tax.Value / 100 + 1)).ToString("n" +
                                                                                                       currency.
                                                                                                       decimalCount)
                                           : p.specialPrice.Value.ToString("n" + currency.decimalCount);
                    sb.AppendFormat(
                        "<h3><span style='text-decoration:line-through;'>{2}{0}</span><span style='margin-left:10px;'>{2}{1}</span></h3>",
                        sellingPrice, specialPrice, currency.symbol);
                }
                else
                {
                    sb.AppendFormat("<h3><span>{1}{0}</span></h3>", sellingPrice, currency.symbol);
                }
            }

            sb.Append("<p>");
            sb.Append(HttpUtility.HtmlEncode(p.details).ToHtmlBreak());
            sb.Append("</p>");
            sb.Append("<p><a target='_blank' href='");
            sb.Append(productpage);
            sb.Append("'>Go to product page</a></p>");
            sb.Append("</div>");

            blogEntry.Content.Content = sb.ToString();
            blogEntry.Content.Type    = "xhtml";
            blogEntry.Authors.Add(new AtomPerson());
            blogEntry.Authors[0].Name  = p.MASTERsubdomain.organisation.users.First().ToFullName();
            blogEntry.Authors[0].Email = p.MASTERsubdomain.organisation.users.First().email;
        }