-1

次のステップを分割しないことが可能かどうか疑問に思っています...

Button b = new Button()
{
    // You can access Attributes here, but only get, not set.
    ID = "btnExample",
    Text = "Click Me"
};

b.Attributes.Add("onclick", "alert('hello, world')");

前もって感謝します。

4

1 に答える 1

1

Buttonからドライブして、コンストラクターに追加できます。

class MyButton: Button
{
    MyButton(MyAttributes atr)
    {
       for each (elm in atr)
       {
          base.Attributes.Add(elm.Key, elm.Value);
       }
    }
}
于 2012-10-16T13:47:52.290 に答える