Esempio n. 1
0
        private void AddAdvertisement(Advertisement ad)
        {
            HtmlGenericControl outer = new HtmlGenericControl("div");

            outer.Attributes.Add("class", "ad" + (ad.Boosted ? " boost" : ""));

            HtmlGenericControl title = new HtmlGenericControl("div");

            title.Attributes.Add("class", "title");
            title.InnerHtml = "<h2>" + ad.Title + "</h2>";
            outer.Controls.Add(title);

            HtmlGenericControl posted = new HtmlGenericControl("div");

            posted.Attributes.Add("class", "created");
            posted.InnerHtml = "<p>Posted " + (ad.Anonymous ? "<strong>anonymously</strong>" : "") + " on " + ad.GetCreationDate() + " and has " + ad.Views + " views</p>";

            outer.Controls.Add(posted);

            HtmlGenericControl description = new HtmlGenericControl("div");

            description.Attributes.Add("class", "description");
            description.InnerHtml = "<h3>" + ad.Description + "</h3>";
            outer.Controls.Add(description);

            HyperLink hyperlink = new HyperLink();

            hyperlink.Text        = "Edit Listing >>";
            hyperlink.NavigateUrl = "~/Edit/" + ad.Id;
            outer.Controls.Add(hyperlink);

            Listings.Controls.Add(outer);
        }