开发者

Custom container control

I'm trying to create a CollapsiblePanel control, which is essentially just a panel which has a header which can be used to expand / collapse the body. I've got an example of it working on a page (inline) but now what to make it a reusable control that can be used as follows

<cc:CollapsiblePanel runat="server" Header="This is a collapsible panel">  
    <asp:Label runat="server" Text="This is the contents of the panel" />  
</cc:CollapsiblePanel>

So, I want the CollapsiblePanel to render the header, the beginning of the container,开发者_如何学Python then the contents of the container (i.e. the label in this case), and finally the end of container.

I'm unsure how to do this properly. I've seen some examples which override the rendering methods in order to insert controls at the right points, but it seems very hack-y.

What is the 'proper' way to do something like this? (.NET 4.0 if that makes a difference)


Overriding the rendering methods is the best way to do this. You would use RenderBeginTag and RenderEndTag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜