开发者

User control "ascx" file with C#

I have a user control, basically consists of a tree view and also a drop down list.. The user control shows something like

(For the tree view)

  Books
    Learn Algebra in 24hrs (30)
    Learn Calculus in 1 week (16)

(For the Drop Down)

--- Books ----
Learn Algebra in 24hrs (30)
Learn Calculus in 1 week (16)

the designer wants to be able to set a property to "true" or "false" in the ascx file that will hide the count on the right (if true shows, if false hides). The count comes from a database along with the product name.

How can I achieve this?, the do not want to deal with C#, but want to be able to deal with the "ascx开发者_运维知识库" file.

Thank you in advance


Create a public property in your User Control, which can be set in the HTML when you use the control.

using System;

namespace RohmPortal.Portal.Controls
{
    public partial class WebUserControl1 : System.Web.UI.UserControl
    {
        public bool DisplayTitle { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

Used like.

<uc2:WebUserControl1 ID="WebUserControl11" DisplayTitle="false" runat="server" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜