Asp. NET in-page "user Control and parent page" and "User control and user control" method calls

Source: Internet
Author: User

In a user control, gets the method of the parent page

1: Method has no parameters (Userinfor ())

String userinfor = Convert.ToString (This. Page.gettype (). GetMethod ("Userinfor"). Invoke (this.    Page, null)); The value obtained is the type of object

2: Method has parameters (userinfor (int a,string b))

String userinfor = Convert.ToString (This. Page.gettype (). GetMethod ("Userinfor"). Invoke (this. Page, new Object[] { " parameter 1"," parameter 2" } ));

Call between the user control and the user control:

Gets the parent page, p = this. Parent.page; Gets the child control of the parent page UserControl UC = P.findcontrol ("Tj_receiptlist2") as UserControl; Type PageType = UC. GetType ();//Parent class method name MethodInfo mi = Pagetype.getmethod ("Loading");//parameter mi. Invoke (UC, new object[] {"Parameter 1", "Parameter 2"});

Attention:
The method that is called by the parent page or other user control must be public!

Reprinted blog: http://www.cnblogs.com/over140/archive/2008/06/16/1222908.html

Asp. NET in-page "user Control and parent page" and "User control and user control" method calls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.