Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please Any buddy help me how to call user control inside user control.
I have to user control so that i want to call all the methods of one user control to other.
so give me some code so that i can implement in my project.
Posted
Comments
Maciej Los 6-Jun-13 11:16am    
What have you done till now?
Where are you stuck?
We don't see your code. How can we help you without knowing with which part of code do you have a problem?

1 solution

Assuming user control A has a reference to User Control B...

Assuming the methods yo u want to access are public.

From within A you can simply do

C#
instanceOfB.SomeMethod();


If you want to access methods of A from B in the same situationm, you will have to give B a reference to A.

One way to do this would be, in A

C#
B.InstanceOfA = this;


where InstanceOfA is a property in B

Now B can call methods of A using

C#
InstanceOfA.SomeMethod();


There are better ways of handling this but they all depend on what sort of project you're dealing with - and you haven't given us a lot to go on!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900