1

このように、文字列や数値などのプロパティに値を割り当てることができます。

<asp:Control property="stringvalue" />

ただし、プロパティタイプが複雑なもの(クラスタイプ)の場合は、次のようにする必要があります。

<asp:Control property=<%#Value%> />

次に、データバインディングコマンドを呼び出して値を設定します。

一部のシナリオでは、databindingコマンドを呼び出すことが実行可能ではありません。その場合、すべてのプロパティをプログラムで設定する必要がありますが、宣言的に設定することをお勧めします。

4

1 に答える 1

0

多分私は何かが欠けています。ただし、複合型プロパティを使用する場合は、これを試してください。

[TypeConverter(typeof(ExpandableObjectConverter))]
public class Foo
{
    public string Property1 { get; set; }
    public string Property2 { get; set; }
}

public class FooCtl : WebControl
{
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), NotifyParentProperty(true)]
    public Foo FooProp { get; private set; }
}

<cc1:FooCtl ID="FooCtl1" runat="server" FooProp-Property1="Value1" FooProp-Property2="Value2" />
于 2010-03-05T16:20:32.300 に答える