当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: