有一继承DropDownList的Web自定义控件,现在要把此DropDownList当成参数传递,请问代码该如何写?namespace Test.WebControl
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:StringItemDDL runat=server></{0}:StringItemDDL>")]
    public class TestDDL : System.Web.UI.WebControls.DropDownList
{
...
[Bindable(false), Category("Appearance"), DefaultValue("")]
 #region Dict
    public System.Type DictType
    {
        set
        {
 //下面这个DropDownList1该如何写?
            DictLookUpFactory.Create(ref DropDownList1, value);
        }
    }
    #endregion
....
}

解决方案 »

  1.   

    如果不用ref 就可用this.如果一定要ref的话可以声明个变量如DropDownList ddl = this;
    ref ddl
      

  2.   

    namespace Test.WebControl
    {
        [DefaultProperty("Text")]
        [ToolboxData("<{0}:StringItemDDL runat=server></{0}:StringItemDDL>")]
        public class TestDDL : System.Web.UI.WebControls.DropDownList
    {
    ...  private DropDownList ddl = new DropDownList(); [Bindable(false), Category("Appearance"), DefaultValue("")]
      #region Enable
             public override bool Enabled
             {
                 get
                 {
    //以下若换成 "return this.Enabled;"会出错, 为什么?
                     return ddl.Enabled;
                 }
                 set
                 {
    //以下若换成 "this.Enabled = value;"会出错, 为什么?
                     ddl.Enabled = value;
                 }
             }
             #endregion  public TestDDL()
             {
                 DropDownList ddl = this;
             }
    ....
    }