Properties 将唯一id属性添加到Episerver Composer块
需要在composer选项卡中添加唯一的ID属性,最好的方法是什么?下面是我的尝试:Properties 将唯一id属性添加到Episerver Composer块,properties,composer-php,episerver,episerver-6,Properties,Composer Php,Episerver,Episerver 6,需要在composer选项卡中添加唯一的ID属性,最好的方法是什么?下面是我的尝试: [PageTypeProperty( EditCaption = "UniqueID", HelpText = "UniqueID", Type = typeof(PropertyString), //DisplayInEditMode=false, Tab = typeof(ComposerTab)
[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-Edit模式下(当我检查此内容块的属性时),我没有在文本框中看到输入的唯一ID
请说明设置此GUID属性的正确方法和位置。谢谢
稍后编辑:
这个例子描述了我的方法
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" %>
BaseContentFunction派生自UserControl、IPageSource和IFunctionSource
BaseComposerFunctionData是从TypedPageData派生的,我不确定这是否有效,但您能在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();
}
我不确定这是否有效,但您能在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();
}
该代码看起来会导致堆栈溢出异常。。。你的财产支持域在哪里?泰德:我在原始帖子中添加了详细信息。这是否回答了您的问题?该代码看起来会导致堆栈溢出异常。。。你的财产支持域在哪里?泰德:我在原始帖子中添加了详细信息。这回答了你的问题吗?谢谢你andreasnico!不幸的是,我得到了
错误15'MyProject.Templates.ComposerFunctions.BCATextBlock.SetDefaultValues(System.Net.Mime.ContentType)':没有找到合适的方法覆盖SetDefaultValues lineah上的,这是在episerver 7+中首次实现的。抱歉:(谢谢andreasnico!不幸的是,我收到了错误15'MyProject.Templates.Composer Functions.BCATextBlock.SetDefaultValues(System.Net.Mime.ContentType)':没有找到合适的方法覆盖SetDefaultValues lineah上的
,这是在episerver 7+中首次实现的。抱歉:(