简体   繁体   中英

Getting ASP.NET Source Representation of Programmatically Created Page

Im creating a page generator for ASP page. It takes XML input, and then converts it into ASPX representation.

During the process of conversion, here's some code i used,

var page = new Page();
var pnlUpdate = new UpdatePanel();
page.Controls.Add(pnlUpdate);

Theoritically, it should creates ASP file like this,

<% Page ...>
....
....
<asp:UpdatePanel>
</asp:UpdatePanel>

How do i get the source representation of my programmatically created page object? Using Filter or catching the HttpRespose output gives me the parsed HTML output, not the ASP one.

To my knowledge there is no code in .Net Framework that will convert control tree into APSX page.

You can write your own version (especially if you have very limited set of allowed control/properties) by walking control tree and generating ASPX as you go. Note that you'd need to know what properties are changed from default values...

It probably would be easier to go directly from XML to ASPX, you may be even able to have XSLT transformation to do so.

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