简体   繁体   中英

How to get raw markup of child controls at runtime

I am trying to create an ASP.net server control for displaying formatted code, using this library: http://www.manoli.net/csharpformat/

Here's the trick: I want be able to express code blocks like this...

<custom:CodeFormatter runat="server">
<asp:Label runat="server" ID="something" Text="my text" />
<asp:Image runat="server" ID="something" ImageUrl="header.jpg" />
</custom:CodeFormatter>

...but not have the inner tags actually execute. I want the Label & Image to be seen by CodeFormatter as raw text, not parsed as real server tags.

So my question is, how to prevent the Label from actually rendering as such? And how to access everything within the custom:CodeFormatter as raw, literal text?

My workaround right now is to encode the <>'s as &lt; and &gt;. I'd love not to do that.

Thanks!

How about extending your control to use ITemplate. Here is a article that explains how to extend a control.

http://www.devx.com/codemag/Article/32182

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM