Link to home
Start Free TrialLog in
Avatar of ARACK04
ARACK04

asked on

circular reference

I have two different user controls.  Each control must reference the other.  The <% reference tags are generating a compiler error for a circular reference.  How can I get around this?
Avatar of kmaicorp
kmaicorp

Not sure about ASP.NET but in C#, if you put them in the same namespace, this appears to resolve the problem. I've come across something like this in WinForms.
SOLUTION
Avatar of aaronfeng
aaronfeng

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ARACK04

ASKER

>>Do they each contain instances of the other (which would be a true circular reference problem)

YES
Uh... if A contains an instance of B which contains an instance of A...  How did you expect that to compile?

(The run-time instantiates an A object, which includes instantiation of a contained B object, which includes instantiation of a contained A object, which includes instantiation of a contained B object, which...)

Depending on what it is you're trying to accomplish (perhaps you can explain more why these two controls are including instances of each other?), aaronfeng might have the right idea above...
Avatar of ARACK04

ASKER

Well by your logic, how could you ever get a linked list to compile?  Shouldn't an instance of A should contain an instance of B, which is set to NULL until I give it a value, and vice versa fpr B.
The only way you can get around circular reference is do what I said above, or put everything in one project.

Cheers,

Aaron
Avatar of ARACK04

ASKER

When you say a third project, are you talking about a third user control?
You are getting circular reference error because you have two projects are referencing each other right?  When I said a third project, I don't mean a user control, it's a project the keeps all your common code that both of your projects need to access.

Cheers,

Aaron
Avatar of ARACK04

ASKER

I only have one project (or website, I'm using vis web developer).  I have two user controls which each have references to each other.
I think we are not talking about the same thing, can you paste some code?

Cheers,

Aaron
Elements in linked lists do not automatically contain instances of each other; if they did, they'd experience the same errors.  Such elements contain field variables of each other's types (i.e., A would contain a field variable of type B), which can then be set by outside code sometime after instantiation.

I agree with aaronfeng that there appears to be some terminology confusion here, and that some sample code would be extremely illustrative...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial