Parsing HTML on aspx page

M

Manmohan Gupta

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top