How to call method in user control to form1
can someone help mi with these??
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nilanka DharmadasaPosted Jan 20, 2010, 3:53 AM
It's easy.
1. First you create a usercontrol and write a public method inside that class.
2. Then from your windows application project, you add a refernce to this usercontrol project.
3. Then you can see the user control in the toolbox of your windows application project.
4. You drag a usercontrol to your form. What this actually does is adding a Usercontrol object to your form class.
5. Then you check the name of the usercontrolobject added to the form. You can check this name by looking at the property window of the usercontrol added.
6. Then in the form, you can call the method as below.
usercontrolobjectname.Methodname();
Check my code. I have done the same thing in my code. You will easily understand what I say.
Please do not forget to tick 'Do you like this answer' checkbox, if this helps you.
Lalit MPosted Jan 20, 2010, 3:48 AM
public void Test1_fillPageType()
{
Test1.fillPageType();
}
/*** wucCourseContent.ascx.cs ***/
WucMainPage1.Test1_fillPageType();
Santhosh NPosted Jan 20, 2010, 3:32 AM
uc1.publicmethod(..)