Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
What I want to do is: At some point (say, during the OnLoad event) scan the page for directives, take actions to implement those directives, and remove the directives from the text, similar to the way that Wikipedia will replace {TOC} with a dynamically generated table of contents. The only part of the "how to" I cannot figure out is how to get and then alter the text of the page during the page's life cycle.

Right now I'm doing this sort of thing with Javascript, but that relies on my users having Javascript enabled, with is not a safe assumption. Another option would be to use a "shell" page and load the content from a text file that I can manipulate before embedding it. I think that changing the text in-place would be faster, though, so I'd like to try that first.

My site uses a master/child construction, if that makes any difference.

So, any suggestions?
Posted

1 solution

Hello,

Have you allready tried the Response.Filter?

Here is an example of using it (used to do modifications to the HTML source that it will be XHTML-Compilant):
http://aspnetresources.com/articles/HttpFilters[^]

You can attach the filter anywhere you want in the page-cycle. If you want to process each request with the filter, you can attach the filter in the global.asax Application_BeginRequest event. If you do so, you need to check that the content-type is 'text/html'.

Hope this helps.

Best regards,
Stops
 
Share this answer
 
Comments
Gregory Gadow 7-Mar-11 15:40pm    
That is a very intruiging idea, thanks. Never heard of that property before, and the BeginRequest thing looks interesting.
Gregory Gadow 9-Mar-11 12:19pm    
Many thanks! Request.Filter does the trick, and I'm writing out my solution as an article.
Christoph Keller 10-Mar-11 2:28am    
You're welcome, I'm happy that I was able to help.
Would love to read your article about the Response.Filter!
Gregory Gadow 10-Mar-11 9:51am    
http://www.codeproject.com/KB/aspnet/serversidetoc.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900