Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Experience is something you don't get until just after the moment you needed it
Posted (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 by travisowens
Experience is something you don't get until just after the moment you needed it

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...