travisowens Posted August 5, 2004 Posted August 5, 2004 I have a table object that I created in my application and I need to extract the HTML markup from it. Is there a way to have ASP.Net parse Web Controls to HTML markup so I can munipulate the markup within my application? I need something generic, not specific to just Table objects. If nothing existis internal to .Net (but I would be surprised if the ASP.Net rendering engine isn't exposed) then I would need a free solution (even if I have to roll my own). Preferably I would hope if the HTML engine is exposed it would also render the HTML in a way compatible to the current user's browser, like how ASP.Net web forms work already. Quote Experience is something you don't get until just after the moment you needed it
*Gurus* Derek Stone Posted August 5, 2004 *Gurus* Posted August 5, 2004 Yes, simply render the controls. [url=http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIControlClassRenderControlTopic.asp]Control.RenderControl[/url](writer) Quote Posting Guidelines
travisowens Posted August 5, 2004 Author Posted August 5, 2004 (edited) At this point I'm experimenting with the following code but my HTML just doesn't seem to be generating. I'm doing a response write to see if the HTML is being written. Table menu = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Text = "TestCell"; row.Cells.Add(cell); menu.Rows.Add(row); String body = String.Empty; String subject = String.Empty; //Control control = null; StringWriter sw = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(sw); menu.RenderControl(writer); body = sw.GetStringBuilder().ToString(); if (writer != null) writer.Close(); if (sw != null) sw.Close(); Response.Write(body); Edited August 5, 2004 by travisowens Quote Experience is something you don't get until just after the moment you needed it
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.