Last post Apr 09, 2007 04:50 AM by Raymond Wen - MSFT
Apr 04, 2007 04:28 PM|Akrion|LINK
Recently in a project I have been working on I was able to create a “framework” which basically was dynamically loading user controls and providing some means
of communication between them and the main host forms. Basically what we ware doing is with the help of the attributes we ware able to “label” some controls as system controls and them at run time create an instance of them and load them dynamically with reflection
in the application. This provided great usability and extensibility of the app.
What I am trying to do now is to create a better framework but this time for the Web. I would like to use a similar principle where I label some user controls (ascx
pages) with certain attribute and then load it at run time on certain pages dynamically. My experience on the web site is not as extensive as on the application and the problems we are running into are that although reflection works great and it finds the
user control when it loads it on the page (via LoadControl or Controls.Add) the user control is blank. If however everything is done dynamically (the control is created at run time and then this control is added to the page dynamically) it works and the user
control appears. This is not what we want since takes out the design aspect and the use of the designer to make the user control look good.
So in a nutshell we want is to be able to use the designer to create a good looking control and then label it with an attribute so that with Reflection we can instantiate
the control at run time and add it to the web page, which will be the host probably having a web panel or a web tab control.
Apr 06, 2007 06:34 AM|Raymond Wen - MSFT|LINK
Apr 06, 2007 05:03 PM|Akrion|LINK
Big thanks for your reply. We tried what you suggested and what happens is that we can easily find the control with Reflection but when the user control (the ascx) file is added to the page its always blank. We add controls to the user control. We build the
assembly and then when at run time we instantiated the user control (after we have found it with reflection) its always blank ...
Thanks again for your help.
Apr 09, 2007 04:50 AM|Raymond Wen - MSFT|LINK