Deleting everything from a webpage

  • Thread starter Thread starter Dylan Parry
  • Start date Start date
D

Dylan Parry

Hi,

I've written a library that uses just one ASPX file to display many
different pages, and this single ASPX contains only the bare minimum of
HTML, ie. html, head and body elements. Now I have been asked to output
some XML using the same library and ASPX file, so I need a way of being
able to completely remove all traces of the HTML within the ASPX file
and outputting a stream of XML instead.

Is there any way that I can remove *all* content from a page, even the
elements that aren't actually defined within the library? Ie. wipe the
canvas clean and start from scratch?

Cheers,
 
Dylan said:
Is there any way that I can remove *all* content from a page, even the
elements that aren't actually defined within the library? Ie. wipe the
canvas clean and start from scratch?

Typically I have found the answer within moments of asking the question.
It would appear that using "this.Controls.Clear()" will do the trick
just nicely. Of course, I welcome any other suggestions!
 
Dylan,

While you could certainly do this, why not have a separate page that has
no content in the ASPX part of it, and in the code-behind, returns your XML.
It would definitely be better from a maintinence standpoint.

Hope this helps.
 
Nicholas said:
While you could certainly do this, why not have a separate page that has
no content in the ASPX part of it, and in the code-behind, returns your XML.
It would definitely be better from a maintinence standpoint.

That's the way I'd normally go about it, but this time I had to reuse
the existing file. The reasons are quite silly, and there's no point in
me arguing with them (management decisions etc), so I'm stuck with my
pseudo-solution ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top