Is there a way to parse the HTML content of an aspx page
into a control object?
I tried this code:
Page pg = new Page();
Control c = pg.ParseControl("<form id=\"Form1\"
method=\"post\" runat=\"server\"></form>");
But it throws an exception:
Object reference not set to an object
Stack Trace:
" at System.Web.UI.BaseParser.MapPath(String path,
Boolean allowCrossAppMapping)\r\n at
System.Web.UI.BaseParser.MapPath(String path)\r\n at
System.Web.UI.TemplateParser.ParseTemplateInternal (String
content, HttpContext context, String baseVirtualDir)\r\n
at System.Web.UI.TemplateParser.ParseTemplate(String
content, HttpContext context, String baseVirtualDir)\r\n
at System.Web.UI.TemplateParser.ParseControl(String
content, HttpContext context, String baseVirtualDir)\r\n
at System.Web.UI.TemplateControl.ParseControl(String
content)\r\n at ConsoleApplication1.Class1.Load3() in
c:\\documents and settings\\mgupta\\my documents\\visual
studio projects\\webapplication21\\consoleapplication1
\\class1.cs:line 34"
|