2010-02-26 65 views
0

我有一個ASP用戶控件QuestionWithAnswer (.ascx) : BaseQuestion : UserControl 和ControlDesigner QuestionDesigner : UserControlDesigner。 現在我用的DesignerAttribute來控制和名牌關聯:Visual Studio使用UserControlDesigner而不是CustomDesigner

[Designer(typeof(QuestionDesigner))] 
public class BaseQuestion : UserControl 

所有類型都在同一組件(WEB應用)。 但它仍然加載UserControlDesigner而不是我的。 我必須把我的設計師放在單獨的裝配中嗎? 我想asp頁面設計者找不到設計師。

thx! 月


演示代碼:

public class FragenDesigner : UserControlDesigner 
{ 
    private DesignerActionList _actionList; 
    private DesignerVerb[] _verbs; 

    public override DesignerActionListCollection ActionLists 
    { 
     get 
     { 
      if (_actionList == null) 
      { 
       _actionList = new DesignerActionList(new System.Windows.Forms.TextBox()); 
       _actionList.AutoShow = true; 


       ActionLists.Add(_actionList); 
      } 
      return base.ActionLists; 
     } 
    } 

    public override DesignerVerbCollection Verbs 
    { 
     get 
     { 
      if (_verbs == null) 
      { 
       _verbs = new DesignerVerb[] 
         { 
          new DesignerVerb("test", onblabla), 
         }; 

       Verbs.AddRange(_verbs); 
      } 

      return base.Verbs; 
     } 
    } 

    private void onblabla(object sender, EventArgs e) 
    { 
     MessageBox.Show("blabla"); 
    } 
} 

回答

1

還好已經有一個答案:http://msdn.microsoft.com/en-us/library/system.web.ui.design.usercontroldesigner.aspx

備註

沒有開發優勢 創建自己的設計師從UserControlDesigner衍生 。爲了增強 自定義控件的設計時體驗,請從CompositeControl獲取控件 ,並從 CompositeControlDesigner派生控件 。在那個 的情況下,你不會使用.ascx文件 作爲你的ASP.NET標記。

在我的情況下,不可能更改爲CompositeControls。 相信我,我更喜歡Composite/WebControls ...

相關問題