开发者

Custom web control. how to render child controls

开发者 https://www.devze.com 2023-01-09 10:23 出处:网络
I\'m trying emulate the IE Webcontrols Pageview system. Basically I have <c:Multipage> <c:pageview>

I'm trying emulate the IE Webcontrols Pageview system.

Basically I have

<c:Multipage> <c:pageview>

[Block of ASP.NET / HTML]

</c:pageview> (More pageviews)</c:Multipage>

And I want to simply render the inner text of the pageview.

I've tried

protected override void AddParsedSubObject(object obj) { ... ControlList.Add((Control)obj); ... }

and

Render(HtmlTextWriter output) { ... foreach (Control c in ControlList) c.RenderControl(); ... }

It seems to render simple things but any more comp开发者_Go百科lex set ups it makes mistakes on. I don't think this is the way to do it at all. I'm having difficulty finding out how I am supposed to be able to just render this. And whether I should treat it as text or child controls


You shouldn't need to explicity call Render. If the control is part of your page's control tree, it will get rendered.


It generally depends on whether or not you are display effectively read-only information or control information that would require view-state information. You can output raw HTML if it's read-only just fine but if it contains controls and requires view-state interaction then you'll want to create actual control objects and insert them into the containing object in the code behind.

It really depends on your specific situation, but it sounds like you could just output raw html into a generic DIV control or something, without knowing the specifics though it's a little tough to point you one way or the other.

0

精彩评论

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