Use ASP.Net server control code generation from .ashx
Posted
by Matt Dawdy
on Stack Overflow
See other posts from Stack Overflow
or by Matt Dawdy
Published on 2010-04-28T18:46:01Z
Indexed on
2010/04/28
18:47 UTC
Read the original article
Hit count: 427
I'm trying to take an existing bunch of code that was previously on a full .aspx page, and do the same stuff in a .ashx handler.
The code created an HtmlTable object, added rows and cells to those rows, then added that html table the .aspx's controls collection, then added it to a div that was already on the page.
I am trying to keep the code in tact but instead of putting the control into a div, actually generate the html and I'll return that in a big chunk of text that can be called via AJAX client-side.
HtmlTable errors out when I try to use the InnerHtml property (says it isn't supported), and when I try RenderControl, after making first a TextWriter and next an HtmlTextWriter object, I get the error that Page cannot be null.
Has anyone done this before? Any suggestions?
© Stack Overflow or respective owner