How do I expose a visible property of an image inside a custom control (C #)?

Problem:

A control that shows each user who checks that they have passed out of a possible four.

My decision:

Create a custom control that has a quiz name and tick the checkbox at the end of each quiz name that I would like to make visible when they pass the quiz.

The actual custom control is inside my master page.

From reading other posts, I understand that I need to make the image.visible property public in the control code. I've tried this several ways and haven't had much luck.

So how can I show the .visible property of the image inside my custom control?

Thanks for any advice.

+1


a source to share


3 answers


Try something like this:



public Boolean ImageIsVisible
{
    set { this.yourImage.Visible = value; }
    get { return this.yourImage.Visible; }
}

      

+6


a source


Ways I can think of ...

In the USER control, just set the image to be public and not private by default, but it displays ALL items.

Another is to create a property at the user control level that goes to ex:

public Boolean ImgVisible
{
  get { return this.YourImageControl.Visible; }
  set { this.YourImageControl.Visible = value; }
}

      



Or just create as a function in a custom control ...

public void ImgVisible( Boolean ShowIt )
{
  this.YourImageControl.Visible = ShowIt;
}

      

Sorry missing the part about the master page ... As a web control, as long as the control is visible from the IDE (visual designer) of your form, you can reference it directly in the definition of the partial class of the CONTROL code by explicit reference ...

public Boolean ImgVisible
{
   get { return ImgControl.Visible; }
   set { ImgControl.Visible = value; }
}

      

+1


a source


I am having a problem accessing this content page. Is it correct?

  • I went to code management and added the following property:

    public Boolean ImgVisible { get { return this.imgModule1Passed.Visible; } set { this. imgModule1Passed.Visible = value; } }

  • in the content page code, I use the following:

UserControl control = (usercontrol)this.Page.Master.FindControl("QuizzesPassed1");

Can't I find the property:

Control.ImgVisible

?

I cannot find the control at all.

0


a source







All Articles