0

I've got a user control which contains a number of other user controls.

I need programmatic access to some of the properties of one of the inner controls from the page which contains the outer control.

So, Page contains Outer Control contains Inner Control, and Page needs access to Inner Control's properties.

I could of course create properties in Outer Control which return the corresponding properties in Inner Control, but this would be tedious.

What I would like to do is add a property to Outer Control which returns Inner Control itself, so that Page can access its properties directly:

(In codebehind for Outer Control):

public UserControls_InnerControl InnerControl { get { return this.ctlInnerControl; } }

But when I build the website I get:

The type 'UserControls_InnerControl' is defined in an assembly that is not referenced. You must add a reference to assembly 'App_Web_fc5rstgb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

What the hell? I work programmatically with instances of user controls all the time (for example, adding them dynamically to other controls) and I've never seen this before.

Is there anything I can do?

Edit: Interestingly, it's not the property in OuterControl which exposes InnerControl which is causing the exception. It's the code in Page which consumes this property that errors.

1 Answer 1

1

Try to add the following on the Page that is accessing he inner control:

<%@ Register Src="UserControls_InnerControl.ascx" TagName="uc" TagPrefix="uc1" %>
<%@ Reference Control="~/InnerControl.ascx" %>

Fix the paths as per your application.

Regards

Sign up to request clarification or add additional context in comments.

1 Comment

My word. That really was excruciatingly obvious. Don't judge me! I have a three month old son! And he has a cold!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.