using System;
using System.Web.UI;
using Microsoft.SharePoint.ApplicationPages;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;
namespace Mho.SharePoint.Trials
{
public class EnhancedCreateWebpage : CreateWebPage
{
protected ListFieldIterator listFieldIterator;
protected string template;
public EnhancedCreateWebpage() { }
protected override void OnPreRender(EventArgs e)
{
if (!this.Page.IsPostBack)
{
// Get the templates list
SPList templatesList = this.listFieldIterator.Web.Lists["Page Templates"];
if (TemplateSourceDirectory != null && templatesList.Items.Count > 0)
{
// Just take the first template for demonstration
this.template = templatesList.Items[0]["Template"].ToString();
}
templatesList = null;
this.FindRichTextControl(listFieldIterator);
}
base.OnPreRender(e);
}
private void FindRichTextControl(Control control)
{
foreach (Control childControl in control.Controls)
{
if (childControl.GetType().Equals(typeof(Microsoft.SharePoint.WebControls.RichTextField)))
{
((RichTextField)childControl).Value = this.template;
return;
}
this.FindRichTextControl(childControl);
}
}
}
}
浙公网安备 33010602011771号