How to create ASPX Page Dynamically
See the question and my original answer on StackOverflowYou can use the Page.ParseControl method.
Beware, it does not support everything you can do with a real ASPX or ASHX file, but it works for simple things. An example is available here: Using Page.ParseControl to add new control from Control Tag