需要在作曲家标签中添加唯一的ID属性,这是最好的方法,这是我的尝试:
[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(); }
}
预期行为:每次在页面上添加新文本框时,都应为其分配唯一ID。
这段代码的问题是我在Composer - 编辑模式(当我检查此内容块的属性时)中看不到在文本框中输入的唯一ID
请评论设置此GUID属性的正确方法以及位置。谢谢!
稍后编辑:
http://tedgustaf.com/blog/2011/9/create-episerver-composer-function-with-page-type-builder/ 这个例子描述了我的方法
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派生自UserControl,IPageSource,IFunctionSource BaseComposerFunctionData派生自TypedPageData
答案 0 :(得分:0)
我不确定这是否可行,但您可以在Block.cs中尝试以下操作吗?
[PageTypeProperty(
EditCaption = "UniqueID",
HelpText = "UniqueID",
Type = typeof(PropertyString),
//DisplayInEditMode=false,
Tab = typeof(ComposerTab))]
public virtual Guid UniqueID { get; set; }
public override void SetDefaultValues(ContentType contentType)
{
UniqueID = System.Guid.NewGuid();
}