SuperUser555
SuperUser555

Reputation: 103

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

Upvotes: 0

Views: 1582

Answers (1)

Zachary
Zachary

Reputation: 6532

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" />

Upvotes: 2

Related Questions