Click here to Skip to main content
12,296,307 members (60,593 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3K views
1 bookmarked
Posted

ASP.NET Load WebUserControl programmatically and invoke method using Reflection

, 10 Jan 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Perhaps you should explain a bit regarding the context of this tip.e.g. Why would you want to invoke methods on a user web control that is required to be loaded dynamically? 3 things:1. It sounds to me as a code smell: apparently the control contains logic that is used by other methods...
Perhaps you should explain a bit regarding the context of this tip.
e.g. Why would you want to invoke methods on a user web control that is required to be loaded dynamically?

3 things:
1. It sounds to me as a code smell: apparently the control contains logic that is used by other methods outside of the control. Therefore a better solution would be to encapsulate that logic in a reusable component outside of the webcontrol, so the webcontrol would not need to be loaded dynamically in the first place.

2. Most of the example code demonstrates the use of reflection, which is not specific to web controls and therefore kind of miss the point of this tip/trick.

3. In my opinion also the use of reflection is a code smell. Dynamic execution of methods (without compile-time type checking) should be avoided whenever possible as it may introduce runtime errors and reduces maintainability: code becomes less readable and understandable.

====================================
just because you can, doesn't mean you should.

License

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

Share

About the Author

Herre Kuijpers
Architect Capgemini
Netherlands Netherlands
Currently Herre Kuijpers is employed at Capgemini Netherlands for over 10 years, where he developed skills with all kinds of technologies, methodologies and programming languages such as c#, ASP.Net, Silverlight, VC++, Javascript, SQL, UML, RUP, WCF. Currently he fulfills the role of software architect in various projects.

Herre Kuijpers is a very experienced software architect with deep knowledge of software design and development on the Microsoft .Net platform. He has a broad knowledge of Microsoft products and knows how these, in combination with custom software, can be optimally implemented in the often complex environment of the customer.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 10 Jan 2011
Article Copyright 2010 by Herre Kuijpers
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid