A
Alex
I'm trying to output a webcontrol in a non-standard way. What I want,
is the page to output xml with the html from the webcontrol in a CDATA
element of the XML document. My code looks something like this):
Response.ContentType = "text/xml";
Response.Write("<gateway><![CDATA[");
System.Web.UI.HtmlTextWriter htmlWriter = new
HtmlTextWriter(this.Response.Output);
System.Web.UI.Control control = LoadControl("MyControl.ascx");
control.RenderControl(htmlWriter);
Response.Write("]]></gateway>");
It works great for some controls but when a control is cached (<%@
OutputCache Duration="10" VaryByParam="None" %>) I get the following
exception:
Object reference not set to an instance of an object.
at System.Web.UI.BasePartialCachingControl.Render(HtmlTextWriter
output)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at home.GatewayContent.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\home\gatewaycontent.aspx.cs:line 49
Anyone have any ideas on what to do?
Thanks,
Alex
is the page to output xml with the html from the webcontrol in a CDATA
element of the XML document. My code looks something like this):
Response.ContentType = "text/xml";
Response.Write("<gateway><![CDATA[");
System.Web.UI.HtmlTextWriter htmlWriter = new
HtmlTextWriter(this.Response.Output);
System.Web.UI.Control control = LoadControl("MyControl.ascx");
control.RenderControl(htmlWriter);
Response.Write("]]></gateway>");
It works great for some controls but when a control is cached (<%@
OutputCache Duration="10" VaryByParam="None" %>) I get the following
exception:
Object reference not set to an instance of an object.
at System.Web.UI.BasePartialCachingControl.Render(HtmlTextWriter
output)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at home.GatewayContent.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\home\gatewaycontent.aspx.cs:line 49
Anyone have any ideas on what to do?
Thanks,
Alex