protected void btnScenario1_Click(object sender, EventArgs e)
        {
            ClientSideSharePointService csomService = new ClientSideSharePointService(this.Context);
            string scenario1Page    = String.Format("scenario1-{0}.aspx", DateTime.Now.Ticks);
            string scenario1PageUrl = csomService.AddWikiPage("Site Pages", scenario1Page);

            csomService.AddHtmlToWikiPage("SitePages", txtHtml.Text, scenario1Page);
            this.hplScenario1.NavigateUrl = string.Format("{0}/{1}", Request.QueryString["SPHostUrl"], scenario1PageUrl);
        }
        protected void btnScenario2_Click(object sender, EventArgs e)
        {
            ClientSideSharePointService csomService = new ClientSideSharePointService(this.Context);

            if (csomService.AddList(170, new Guid("192efa95-e50c-475e-87ab-361cede5dd7f"), "Links", false))
            {
                csomService.AddPromotedSiteLink("Links", "Gapps on codebox", "http://codebox/gapps");
                csomService.AddPromotedSiteLink("Links", "Bing", "http://www.bing.com");
            }

            string scenario2Page    = String.Format("scenario2-{0}.aspx", DateTime.Now.Ticks);
            string scenario2PageUrl = csomService.AddWikiPage("Site Pages", scenario2Page);

            bool twoColumnsOrMore = false;
            bool header           = false;

            switch (drpLayouts.SelectedValue)
            {
            case "OneColumn":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.OneColumn, scenario2Page);
                break;

            case "OneColumnSideBar":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.OneColumnSideBar, scenario2Page);
                break;

            case "TwoColumns":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.TwoColumns, scenario2Page);
                twoColumnsOrMore = true;
                break;

            case "TwoColumnsHeader":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.TwoColumnsHeader, scenario2Page);
                twoColumnsOrMore = true;
                header           = true;
                break;

            case "TwoColumnsHeaderFooter":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.TwoColumnsHeaderFooter, scenario2Page);
                twoColumnsOrMore = true;
                header           = true;
                break;

            case "ThreeColumns":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.ThreeColumns, scenario2Page);
                twoColumnsOrMore = true;
                break;

            case "ThreeColumnsHeader":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.ThreeColumnsHeader, scenario2Page);
                twoColumnsOrMore = true;
                header           = true;
                break;

            case "ThreeColumnsHeaderFooter":
                csomService.AddLayoutToWikiPage("SitePages", WikiPageLayout.ThreeColumnsHeaderFooter, scenario2Page);
                twoColumnsOrMore = true;
                header           = true;
                break;

            default:
                break;
            }

            Guid          linksID = csomService.GetListID("Links");
            WebPartEntity wp2     = new WebPartEntity();

            wp2.WebPartXml   = csomService.WpPromotedLinks(linksID, string.Format("{0}/Lists/{1}", Request.QueryString["SPHostUrl"], "Links"), string.Format("{0}/{1}", Request.QueryString["SPHostUrl"], scenario2PageUrl), "$Resources:core,linksList");
            wp2.WebPartIndex = 1;
            wp2.WebPartTitle = "Links";

            int webpartRow = 1;

            if (header)
            {
                webpartRow = 2;
            }

            csomService.AddWebPartToWikiPage("SitePages", wp2, scenario2Page, webpartRow, 1, false);
            Session.Add("LastPageName", scenario2Page);

            if (twoColumnsOrMore)
            {
                csomService.AddHtmlToWikiPage("SitePages", txtHtml.Text, scenario2Page, webpartRow, 2);
            }

            this.hplScenario2.NavigateUrl   = string.Format("{0}/{1}", Request.QueryString["SPHostUrl"], scenario2PageUrl);
            this.btnScenario2Remove.Enabled = true;
        }