0

问题在标题中,但是当您使用普通服务器控件时更清楚

<asp:textbox /> 
<CC1:CtrlArticleList SortBy="Title"  ID="compositeControlArticleList" runat="server" />

文本框的属性允许您从下拉列表中进行选择(例如 visibility=...true 或 false)。如何在复合控件中复制它?

自提出问题以来添加了代码:

有人建议使用枚举,但不确定如何设置:

enum SortBY { Date, Title };

        [Bindable(false), DefaultValue(""), Description("The sorting type of the DataPager")]
    public SortBY SortBySomething
    {
        get
        {
            SortBY getDate = SortBY.Date;
            if(getDate == (SortBY)ViewState["SortBy"])
            {
                return SortBY.Date;
            }
            else
            {
                return SortBY.Title;
            }
        }
        set 
        { 
            ViewState["SortBy"] = value; 
        }
    }
4

1 回答 1

0

只需在您的复合控件中设置它们的属性,如下面的MSDN示例。然后,您的公共财产将显示在智能中。如果他们不这样做,您可能需要先重建您的应用程序。

 public class Register : CompositeControl
{
    private Button submitButton;

    // The following properties are delegated to 
    // child controls.
    [
    Bindable(true),
    Category("Appearance"),
    DefaultValue(""),
    Description("The text to display on the button.")
    ]
    public string ButtonText
    {
        get
        {
            EnsureChildControls();
            return submitButton.Text;
        }
        set
        {
            EnsureChildControls();
            submitButton.Text = value;
        }
    }

看到您的评论后,我认为您正在寻找的是(可能不完美;没有测试,但很接近):

public enum SortType{Name,Date}    

public SortType SortBy 
{
    get{
           if(ViewState["SortBy"] != null){
              return (SortType)ViewState["SortBy"];}
           else{return SortType.Date;}
    }
    set{ViewState["SortBy"] = value;}
}
于 2010-03-16T16:23:25.937 回答