Click here to Skip to main content
15,891,372 members
Articles / Web Development / ASP.NET

Call form method from user Control

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
25 Jan 2013CPOL 0  
It's not a good idea to try and call any methods in the form from the user control, it locks the control to a particular form, and means that it can't be re-used later, and the form can't be changed without considering the effects on the control.Instead, create an event in the Control which...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
25 Jan 2013LokkiUA 2 alternatives  
Hi. I have User Control and it shows in the main form in after I click on the button. How I can hide this control after I click on the button that is in the control. OR how can I call main form's method from control? Any suggestions?
Please Sign up or sign in to vote.
25 Jan 2013Sergey Alexandrovich Kryukov
In this respect, user control class is no different from any other class, no matter control or not. You always need to pass something to the instance of the control, something which can be called. It could be: 1) delegate instance, 2) a reference to the class with the method(s), in this case, a...

License

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


Written By
CEO
Wales Wales
Born at an early age, he grew older. At the same time, his hair grew longer, and was tied up behind his head.
Has problems spelling the word "the".
Invented the portable cat-flap.
Currently, has not died yet. Or has he?

Comments and Discussions