views:

383

answers:

3

Problem:

A control that shows each user which quizzes they have passed out of a possible four.

My solution:

Create user control that lists the name of the quizzes and has a checkmark at the end of each quiz name that I would like to make visible when they pass a quiz.

The actual user control is inside of my master page.

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

So how do I expose the .visible property of an image inside of my user control?

Thanks for any advice.

+6  A: 

Try something like this:

public Boolean ImageIsVisible
{
    set { this.yourImage.Visible = value; }
    get { return this.yourImage.Visible; }
}
Andrew Hare
Thx for your help!
Strategon
+1  A: 

hree ways I can think of...

In the USER control, just set the image as public instead of default - private, but that exposes ALL the elements.

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

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

Or, just create as a function in your user control...

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

Sorry, missed part about Master Page... As a web control, as long as control is visible from the IDE (visual designer) of your form, you can refer to it directly in the CONTROL's code-behind partial class definition by the explicit name reference...

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

DRapp
Thx for your help!
Strategon
A: 

I'm having a problem accessing this on the content page. Is this right?

  1. I went to codebehind on control and added the following property:

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

  2. on the content page code behind, I am using the following:

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

Shouldn't I be able to find the property by:

Control.ImgVisible

?

I can't seem to find the control at all.

Strategon
you should cast the Control into your specific subtype, since only it contains the ImgVisible property.
Noam Gal