0
Answer

choosing user controls dynamically at runtime

zseth

zseth

20y
1.6k
1
I am trying to dynamically choose from a selection of user controls at runtime. Based on a specified id field, I want to load the related control which will specify how to format some data passed up through the application. It's for a CMS and i'm trying to dynamically update the attributes for different types of content (ie. an image might have 'src', 'width', 'height'... and a link might have 'href', 'title', 'link text'... and paragraph will just have 'text') I've tried to use the asp:placeholder control to do this with a code behind switch-statement but the placeholder's OnDataBinding causes a nullReferenceExeption which i haven't been able to solve. The only other way i can think of doing this is by outputting the data in a preformatted string but this is a clumsy and inelegant solution, and i won't be able to use the data for updates. any ideas how to get around this (prefferably with the placeholder)???