1

LongString から継承された Episerver にカスタム プロパティがあります。プロパティの値が初めて保存され、正しく取得されます。ただし、連続して保存すると、値は更新されません。SaveData() の前に、プロパティ LoadData() が値を呼び出して古い値にリセットし続けるため、新しい値は DB に保存されません。Itera.MultiProperty ソリューションのコードを参照し、フローをこれと比較しようとしましたが、まだ運がありません。リピーター コントロールを使用してカスタム プロパティに更新パネルがありますが、ページがポストバックされ、保存前に LoadData() が呼び出されます。Episerver 5.2 R2 SP1 を使用しています。ポインタやヘルプをいただければ幸いです。

    public override void LoadData(object value)
    {
        if (value != null)
            _val = value.ToString();
        base.LoadData(_val);
    }

   public override object SaveData(PropertyDataCollection properties)
    {
        return _val;
    }

サンジャイ・ザルケ

4

2 に答える 2

1

最初に PropertyLongString.LongString を設定してから、基本の SaveData メソッドを呼び出す必要があると思います。

これを試して:

public override object SaveData(PropertyDataCollection properties)
{
    this.LongString = _val;
    return base.SaveData(properties);
}

また(これを見てからしばらく経ちました)、私の LoadData オーバーライドについては、次のようなものがあります。

public override void LoadData(object value)
{
    // I'm sending value off to be used somewhere else.

    base.Value = value;
}

base.LoadData() を呼び出していません

于 2010-12-22T12:00:57.487 に答える
1

答えるのが少し遅くなるかもしれませんが、幸運なことにその時、Anders Hattestad の記事を見つけましたEpiServer で非常に優れた洞察力を持つ天才的な男。

私は彼のコントロールを継承し、独自のコントロールをたくさん作成しましたが、それらは魅力的に機能します。

ありがとう。

編集:

Bill のリクエストにより、最終的なコードを以下に示します。記事へのリンクはすでに上に配置されています:)

using System;
using System.Collections.Generic;
using System.Text;
using EPiServer.Core;
using System.Web.UI.WebControls;
using System.Web.UI;
using EPiServer.PlugIn;
using Itera.Property;
using EPiServer.SpecializedProperties;

namespace MyProject.CustomProperties
{
    [PageDefinitionTypePlugIn]
    public class CategoryList : PropertyMulitBase
    {
        public CategoryList()
            : base()
        {
            EditOption.Add(EditOptions.ShowTopTabs, true);

        }
        #region BasePropertys
        PropertyDataCollection basePropertys;
        public override EPiServer.Core.PropertyDataCollection BasePropertys
        {
            get
            {
                if (basePropertys == null)
                {
                    PropertyDataCollection _new = new PropertyDataCollection();
                    _new.Add("Category", new Category());
                    basePropertys = _new;
                }
                return basePropertys;
            }
        }
        #endregion

    }

    [PageDefinitionTypePlugIn]
    public class CategoryItemList : PropertyMulitBase
    {
        public CategoryItemList()
            : base()
        {
            EditOption.Add(EditOptions.ShowTopTabs, true);

        }
        #region BasePropertys
        PropertyDataCollection basePropertys;
        public override EPiServer.Core.PropertyDataCollection BasePropertys
        {
            get
            {
                if (basePropertys == null)
                {
                    PropertyDataCollection _new = new PropertyDataCollection();
                    _new.Add("Category Item", new PropertyPageReference());
                    basePropertys = _new;
                }
                return basePropertys;
            }
        }
        #endregion

    }


    public class Category : PropertySingleBase
    {

        #region PropertyCollection
        PropertyDataCollection innerPropertyCollection;
        object lockObject = new object();
        protected override PropertyDataCollection InnerPropertyCollection
        {
            get
            {
                if (innerPropertyCollection == null)
                {
                    innerPropertyCollection = new PropertyDataCollection();
                    innerPropertyCollection.Add("Category", new PropertyPageReference());
                    innerPropertyCollection.Add("Customise", new PropertyBoolean());
                    innerPropertyCollection.Add("Category Item", new CategoryItemList());

                }
                return innerPropertyCollection;
            }
            set
            {
                innerPropertyCollection = value;
            }
        }
        #endregion
    }
}

これをプロジェクトの下の CustomProperties フォルダーに追加します。

于 2012-02-09T10:38:14.210 に答える