Last post Sep 14, 2008 05:11 PM by jkirkerx
Sep 13, 2008 05:49 PM|kcmonster58|LINK
I used the term "Interfaceable" rather loosely. Here is what I am trying to achieve:
I have a page with a usercontrol. I also have 4 or 5 diffferent versions of that Usercontrol. Each version has the same Properties, Methods, Events (now you know why I used the term "Interfaceable"). Different clients use different versions. As it stands,
I have to build the project differently for each client (wth the appropriate usercontrol on the page). This is obviously not a good way to distribute my app. I'd also like to be able to write customized versions of the control for clients. So, ultimately,
I would like for the correct usercontrol to be loaded at runtime - based on a config file setting or maybe a setting stored in a database. In theory, that setting would be the path to the usercontrol. Given this requirement, what would I put on the page? I
could just put a placeholder and add the usercontrol to that placeholder dynamically at runtime, but that prevents me from being able to have calls to the usercontrols properties and methods from the page codebehinid. Another possible solution I came up with
is to have a "generic" version of the usercontrol, with the same properties, methods, events, etc. The generic uc would have its own placeholder and would load the correct uc (with events) at runtime. I would map the generic uc properties, etc to the dynamically
loaded uc properties, etc and just bubble the events. That way, the page could access the props, etc on the generic uc. Pretty sure this method could work, but it doesnt seem like a very elegant way to do it. Also, any versions of the usercontrol to be used
would have to be contained within the main project, and as I mentioned before, I'd like to be able to have custom versions for specific clients. I wouldn't want to have these custom versions compiled within the main app, but I suppose I could live with it
if I have to. So, anybody have any suggestions that would be better than my "generic" version of the uc?
Sep 14, 2008 05:11 PM|jkirkerx|LINK
This is the server control forum, so I would make a server control based on the latter concept.
I ran into the same issues years ago with program versioning and code unification. I ended up taing the time to learn how to write server control, in which I can place a single control on the page, and just use a server control property enumerator to select
the customer or vendor needed at the time. The property is public so it can be changed in either code behind, or internally inside the control, or an INI file or registry setting that holds common values.
The control took awhile to make, but it saves time and money later on down the road.