Last post Aug 12, 2009 03:57 PM by scott.elliott
Jun 07, 2007 07:13 PM|nileshsawant1|LINK
I have a requirement to create a wrapper control. And I am sure my requirements is something that most of people would have come across.
My web page is going to have few user controls on it. Every user control is supposed to have a textbox on the top that will capture the title of the user control and a close button on the right which when clicked will hide the user control. Pretty much similar
to a webpart. However I dont want to use 2.0 webpart for this since it does a post back for whatever it does.
The way I want to do this is, I want to write a custom panel control called MyWrapper. When I wrap any user control within MyWrapper, what it should do is, it should create a table with first row as a row with a texbox and anything else. Second row with
just one cell and all the child controls of the panel added to it.
Once I have this custom control, then what I can do is, whichever user control needs to have this kind of layout, I can wrap it within the MyWrapper control.
The design I have in mind is, I will create a custom control that inherits from asp panel control and in the render method i will create the table I want and put all the panel child controls within it. I tried a sample code but got few weird erros about
Has someone worked on something like this before. Can you share your designs with me or suggest me few things here?
wrapper control custom panel inherit
Jun 08, 2007 09:10 AM|jwscuba|LINK
I have just started out with custom server controls(I have only written 3 of them), but I think what you might be looking for would actually be to create a custom control that inherits from compositeControl. Composite controls atomatically implements IEnumerable
(which I think is why you are getting the errors). From there you can overide the createChildControls method and build out your panel and label. Then you can create a templated region so you would have a template that you can use to populate the meat of
your wrapper control with your user control or whatever you may wish. I am not sure that this is actually the best way, but it would be the way that I would try to tackle the project.
If there is a better way to do somthing like this I would like to here it also.
Aug 12, 2009 03:57 PM|scott.elliott|LINK
I know this is an old post, but if this answered your question, is there anyway you possibly have an example you can share on how you accomplished this? I have a similar inquiry at