|
-
Oct 13th, 2008, 07:52 AM
#5
I wonder how many charact
Re: ASP.net get page source from Control
It shouldn't be confusing so let me clear it up for you.
The Response.Filter property accepts a Stream class which would enable you to replace tokens as you stated.
The Response.OutputStream is where all controls' Render methods write to. The Filter is another stream you provide which the runtime will apply after ALL Controls and HttpModules have been processed for the request. It is the absolute last stop before the content gets delivered to the client.
You can simply create a shallow user control with no sub-controls on it, and in the Page_Load method, simply assign the Response.Filter property to an instance of your class.
That class has to be inherited from Stream. The link I gave shows you an example of using a simple String.Replace call to replace parts of the html in the Stream's Write method. You could easily use Regex patterns as well.
If you're trying to replace asp.net tokens like <ASP:TEXTBOX> with something else, this won't work for you because it replaces the actual HTML output of those controls, the tokens are interpreted by the ASP.NET parser when a request comes in, and would be a far more difficult endeavor.
Simply copy the linked code (the ReplaceHtml class) exactly, include it your project, and then add a new UserControl to your project. In the code-behind, in the Page_Load method, assign the Response.Filter property as follows:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Filter = New ReplaceHTML(Response.Filter)
End Sub
You can then tweak the Write method in the ReplaceHtml class you copied from the link to replace any part of tokens you wish to find.
Then simply put that UserControl on any page you wish to apply that functionality.
Last edited by nemaroller; Oct 13th, 2008 at 07:58 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|