473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

rendering a web control programmatically.

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(Htm lTextWriter
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:lin e 49

Anyone have any ideas on what to do?

Thanks,
Alex

Nov 19 '05 #1
0 982

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David Whitney | last post by:
All: I have a control that renders a table. As the table is rendered, each row in the table is constructed by creating a run-time (dynamic) object that is derived from an HtmlTableRow. The row...
2
by: Mike Speak | last post by:
I have a user control that I want to use to render 4 menu items (retrieved from db) on the top of each of my asp.net pages. The user control defines a table, with one TR and one TD. Within the...
2
by: Stephen Wolfman | last post by:
I'm rendering an RS report into an image programmatically before printing (using System.Drawing.Printing) it, but it always renders the image based upon the screen resolution of the server that my...
1
by: sonic | last post by:
I generate a button link control in following Manner. Button b = new Button(); b.Click = MyEventHandler(...); If i add this button to current control with: this.Controls.Add( b ); it will...
5
by: Dave A | last post by:
I am writing an ASP.NET tool that will allow the client to create their own online froms. ie the client can add tect boxes, text, drop downs,etc with absolutely no technical skill what so ever....
1
by: Jarod | last post by:
Hey When I put my control into DetailsView in a template I see it and it seems as working ok. After compile it works on the page. But in normal view in designer I don't see my detailsView instead...
3
by: ramesh | last post by:
Hi all, I am facing a problem with the rendering of html into a windows application (C# .NET). I am trying with two possible approaches: 1. Use a control that directly renders the html into...
5
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
1
by: =?Utf-8?B?TUNN?= | last post by:
Is it possible to have .NET controls render as HTML 4.01 Strict compliant? In web.config, there is xhtml conformance, but that does not provide an option for HTML 4.01.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.