Just Code‎ > ‎

EPiServer - Adding and modifying pages from code behind

posted Jan 17, 2010, 1:36 PM by Peter Henell
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Web.WebControls;

namespace EPiServer
{
    public partial class DemoPage : EPiServer.TemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            PageData pd = DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, 3);

            pd.PageName = "Peters testsida";
            DataFactory.Instance.Save(pd, EPiServer.DataAccess.SaveAction.Publish);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            PageData pd = DataFactory.Instance.GetPage(new PageReference(29));
            PageData writeAble = pd.CreateWritableClone();

            writeAble.PageName = "Denna sida är modifierad";
            DataFactory.Instance.Save(writeAble, EPiServer.DataAccess.SaveAction.Publish);
        }
    }
}
Comments