Need to add a unique ID property in a composer tab, what's the best way of doing this and here's my attempt:
[PageTypeProperty(
EditCaption = "UniqueID",
HelpText = "UniqueID",
Type = typeof(PropertyString),
//DisplayInEditMode=false,
Tab = typeof(ComposerTab))]
public virtual Guid UniqueID
{
get { return UniqueID; }
set { UniqueID = System.Guid.NewGuid(); }
}
Intended behaviour: each time a new textbox is added on the page, it should be assigned a unique ID.
Problem with this piece of code is I don't see a unique ID entered in the text box when in Composer - Edit Mode (when I check the properties of this content block)
Please comment on correct way to set this GUID property and where. Thanks!
Later edit:
http://tedgustaf.com/blog/2011/9/create-episerver-composer-function-with-page-type-builder/ This example describes my approach
Block.cs
namespace MyProject.ComposerFunctions
{
[PageType("70421202Efdghajkfgkjd43535",
Name = "Block",
Description = "Block",
Filename = "Block.ascx")]
public class Block : BaseComposerFunctionData
{
[PageTypeProperty(
EditCaption = "UniqueID",
HelpText = "UniqueID",
Type = typeof(PropertyString),
//DisplayInEditMode=false,
Tab = typeof(ComposerTab))]
public virtual Guid UniqueID
{
get { return UniqueID; }
set { UniqueID = System.Guid.NewGuid(); }
}
}
}
Block.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Block.ascx.cs" Inherits="MyProject.ComposerControls.Block" %>
Block.ascx.cs
namespace MyProject.ComposerControls
{
public partial class Block : Dropit.Extension.Core.BaseContentFunction
{
protected override void OnLoad(EventArgs e)
{
if (!IsPostBack)
{
this.DataBind();
}
}
}
}
BaseContentFunction is derived from UserControl, IPageSource, IFunctionSource BaseComposerFunctionData is derived from TypedPageData