Connecting Tech Pros Worldwide Forums | Help | Site Map

Post process an ASP.NET page

Yourself
Guest
 
Posts: n/a
#1: Mar 5 '06
Is there anyway of processing an ASP.NET page after the code behind has run,
but before it's presented as HTML?

What I'm trying to do is alter some of the markup that a content management
system produces, and I don't have access to the source code to recompile any
of the code behind stuff.

I guess I could put a user control on the bottom of every aspx page and in
the Page_Load method, access the controls on the page through
Parent.Page.FindControl("id").

That's what I've been trying to do, but is there any better and more
eloquent way?



Juan T. Llibre
Guest
 
Posts: n/a
#2: Mar 5 '06

re: Post process an ASP.NET page


re:[color=blue]
> What I'm trying to do is alter some of the markup that a content management system produces, and I
> don't have access to the source code to recompile any of the code behind stuff.[/color]

See : http://msdn2.microsoft.com/en-us/library/ms178472.aspx

Page_PreRender is an ideal event for you to do that.
Page_Init might also be a good place.

See the order of page events at :
http://msdn2.microsoft.com/en-us/lib.../dct97kc3.aspx

I must say, however, that if you don't have access to the code-behind
( why is that ? ) doing what you want to do could turn out to be quite tricky.




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Yourself" <invalid@email.address> wrote in message
news:C_GOf.30794$wl.25017@text.news.blueyonder.co. uk...[color=blue]
> Is there anyway of processing an ASP.NET page after the code behind has run, but before it's
> presented as HTML?
>
> What I'm trying to do is alter some of the markup that a content management system produces, and I
> don't have access to the source code to recompile any of the code behind stuff.
>
> I guess I could put a user control on the bottom of every aspx page and in the Page_Load method,
> access the controls on the page through Parent.Page.FindControl("id").
>
> That's what I've been trying to do, but is there any better and more eloquent way?
>
>
>[/color]


Yourself
Guest
 
Posts: n/a
#3: Mar 5 '06

re: Post process an ASP.NET page


"Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message
news:e424h0IQGHA.3804@TK2MSFTNGP15.phx.gbl...[color=blue]
> re:[color=green]
>> What I'm trying to do is alter some of the markup that a content
>> management system produces, and I don't have access to the source code to
>> recompile any of the code behind stuff.[/color]
>
> See : http://msdn2.microsoft.com/en-us/library/ms178472.aspx
>
> Page_PreRender is an ideal event for you to do that.
> Page_Init might also be a good place.[/color]

Ok, Page_PreRender sounds like the ideal place, but (forgive my ignorance),
dosen't this go in the code-behind file for the appropriate page? i.e.
Default.aspx.cs. Therefore, the content management system will already have
this defined in the dll file that the code behind page compiled to.

How can I tell the page (Default.aspx) to use the Page_PreRender method from
a different source? or can't I?
[color=blue]
>
> See the order of page events at :
> http://msdn2.microsoft.com/en-us/lib.../dct97kc3.aspx
>
> I must say, however, that if you don't have access to the code-behind
> ( why is that ? ) doing what you want to do could turn out to be quite
> tricky.
>
>[/color]

All I really want to do is loop through each control (HtmlGenericControl)
and convert the tag name to lowercase, because the CMS outputs tags like
LINK and H1 as it is, which isn't valid XHTML.
[color=blue]
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaņol : http://asp.net.do/foros/
> ===================================
> "Yourself" <invalid@email.address> wrote in message
> news:C_GOf.30794$wl.25017@text.news.blueyonder.co. uk...[color=green]
>> Is there anyway of processing an ASP.NET page after the code behind has
>> run, but before it's presented as HTML?
>>
>> What I'm trying to do is alter some of the markup that a content
>> management system produces, and I don't have access to the source code to
>> recompile any of the code behind stuff.
>>
>> I guess I could put a user control on the bottom of every aspx page and
>> in the Page_Load method, access the controls on the page through
>> Parent.Page.FindControl("id").
>>
>> That's what I've been trying to do, but is there any better and more
>> eloquent way?
>>
>>
>>[/color]
>
>[/color]


Yourself
Guest
 
Posts: n/a
#4: Mar 5 '06

re: Post process an ASP.NET page



"Spam Catcher" <spamhoneypot@rogers.com> wrote in message
news:Xns977D952851D36usenethoneypotrogers@127.0.0. 1...[color=blue]
> "Yourself" <invalid@email.address> wrote in
> news:C_GOf.30794$wl.25017@text.news.blueyonder.co. uk:
>[color=green]
>> That's what I've been trying to do, but is there any better and more
>> eloquent way?[/color]
>
> You can try using the PreRender or the Render events to modify the HTML.
>
> The HTTPModule or HTTPHandlers might be useful too.
>[/color]

Yeah they sound like they might do the trick, but how can get to a pages
controls from a HTTPModule or HTTPHandler? I can't seem to find any
information on that...
[color=blue]
>
>
> --
> Stan Kee (spamhoneypot@rogers.com)
>
> Boycott StarForce!
> http://www.glop.org/starforce[/color]


Juan T. Llibre
Guest
 
Posts: n/a
#5: Mar 5 '06

re: Post process an ASP.NET page


re:[color=blue]
> Ok, Page_PreRender sounds like the ideal place, but (forgive my ignorance),
> dosen't this go in the code-behind file for the appropriate page?
>
> How can I tell the page (Default.aspx) to use the Page_PreRender
> method from a different source? or can't I?[/color]

Why wouldn't you be able to ?

Compile a helper assembly and do whatever you'd like in it,
calling its procedures from your inline page code :

MyPreRenderAssembly.vb:
===================

Imports System
Imports System.Web
Imports System.Web.UI

Namespace myControls

Public Class ControlEvents
Inherits Control

Protected Overrides Sub OnPreRender( e As EventArgs )
Context.Response.Write( "<li> OnPreRender Event!" )
End Sub

End Class

End Namespace



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Yourself" <invalid@email.address> wrote in message
news:dzHOf.30825$wl.3412@text.news.blueyonder.co.u k...[color=blue]
> "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message
> news:e424h0IQGHA.3804@TK2MSFTNGP15.phx.gbl...[color=green]
>> re:[color=darkred]
>>> What I'm trying to do is alter some of the markup that a content management system produces, and
>>> I don't have access to the source code to recompile any of the code behind stuff.[/color]
>>
>> See : http://msdn2.microsoft.com/en-us/library/ms178472.aspx
>>
>> Page_PreRender is an ideal event for you to do that.
>> Page_Init might also be a good place.[/color]
>
> Ok, Page_PreRender sounds like the ideal place, but (forgive my ignorance), dosen't this go in the
> code-behind file for the appropriate page? i.e. Default.aspx.cs. Therefore, the content
> management system will already have this defined in the dll file that the code behind page
> compiled to.
>
> How can I tell the page (Default.aspx) to use the Page_PreRender method from a different source?
> or can't I?
>[color=green]
>>
>> See the order of page events at :
>> http://msdn2.microsoft.com/en-us/lib.../dct97kc3.aspx
>>
>> I must say, however, that if you don't have access to the code-behind
>> ( why is that ? ) doing what you want to do could turn out to be quite tricky.
>>
>>[/color]
>
> All I really want to do is loop through each control (HtmlGenericControl) and convert the tag name
> to lowercase, because the CMS outputs tags like LINK and H1 as it is, which isn't valid XHTML.
>[color=green]
>>
>>
>> Juan T. Llibre, asp.net MVP
>> aspnetfaq.com : http://www.aspnetfaq.com/
>> asp.net faq : http://asp.net.do/faq/
>> foros de asp.net, en espaņol : http://asp.net.do/foros/
>> ===================================
>> "Yourself" <invalid@email.address> wrote in message
>> news:C_GOf.30794$wl.25017@text.news.blueyonder.co. uk...[color=darkred]
>>> Is there anyway of processing an ASP.NET page after the code behind has run, but before it's
>>> presented as HTML?
>>>
>>> What I'm trying to do is alter some of the markup that a content management system produces, and
>>> I don't have access to the source code to recompile any of the code behind stuff.
>>>
>>> I guess I could put a user control on the bottom of every aspx page and in the Page_Load method,
>>> access the controls on the page through Parent.Page.FindControl("id").
>>>
>>> That's what I've been trying to do, but is there any better and more eloquent way?
>>>
>>>
>>>[/color]
>>
>>[/color]
>
>[/color]




Closed Thread