473,548 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Intercepting what ASP.NET renders: how fine-grained?

ASP.NET is a kind of "engine" that takes declarative markup and code and
renders these instructions into presentational forms. And every page is a
class.

With that in mind I'm wondering,

a) how to intercept the rendered output and do further programmatic things
with it;
and
b) how coarse or finely grained the control might be. One could envision the
ASP.NET designers giving you programmatic access to subselections of the
page HTML (e.g. <head> ... </head> <body> ... </body> ). Maybe even a page
hieararchy.

I'm interested in rendering content into various non-HTML forms (pdf, Flash
text, multipart mails) and I'd like the ASP.NET engine to do the hard work
of preprocessing some of this content; these ideas are especially
interesting with the availability of skins, themes, and master pages in
asp.net 2.0.

Barring programmatic access, I suppose I can yank what I want using regular
expressions, but I'm curious if there's a better way.

Thanks,
-KF
Nov 19 '05 #1
4 1377
You could certainly use httphandlers to intercept the outgoing
stream and modify it. This article is a bit off topic but the
code sample does demonostrate how and where to do this:

http://www.eggheadcafe.com/articles/hijacksession.asp

You could also load the rendered output into a DOM
and work with it.

http://www.eggheadcafe.com/articles/parsinghtml.asp

There are a variety of things you could do...

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net

Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com .
http://www.eggheadcafe.com/forums/merit.asp

<ke*****@u.wash ington.edu> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
ASP.NET is a kind of "engine" that takes declarative markup and code and
renders these instructions into presentational forms. And every page is a
class.

With that in mind I'm wondering,

a) how to intercept the rendered output and do further programmatic things
with it;
and
b) how coarse or finely grained the control might be. One could envision
the ASP.NET designers giving you programmatic access to subselections of
the page HTML (e.g. <head> ... </head> <body> ... </body> ). Maybe even
a page hieararchy.

I'm interested in rendering content into various non-HTML forms (pdf,
Flash text, multipart mails) and I'd like the ASP.NET engine to do the
hard work of preprocessing some of this content; these ideas are
especially interesting with the availability of skins, themes, and master
pages in asp.net 2.0.

Barring programmatic access, I suppose I can yank what I want using
regular expressions, but I'm curious if there's a better way.

Thanks,
-KF

Nov 19 '05 #2
you can modify the HTML that is rendered to the screen in the "Render"
method of the page.

or if you want to alter the HTML of every page in your application you can
just inherit from a common base page.

you can definatly use regular expressions to change the HTML at this point.

HTH

cheers

martin.

<ke*****@u.wash ington.edu> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
ASP.NET is a kind of "engine" that takes declarative markup and code and
renders these instructions into presentational forms. And every page is a
class.

With that in mind I'm wondering,

a) how to intercept the rendered output and do further programmatic things
with it;
and
b) how coarse or finely grained the control might be. One could envision
the ASP.NET designers giving you programmatic access to subselections of
the page HTML (e.g. <head> ... </head> <body> ... </body> ). Maybe even
a page hieararchy.

I'm interested in rendering content into various non-HTML forms (pdf,
Flash text, multipart mails) and I'd like the ASP.NET engine to do the
hard work of preprocessing some of this content; these ideas are
especially interesting with the availability of skins, themes, and master
pages in asp.net 2.0.

Barring programmatic access, I suppose I can yank what I want using
regular expressions, but I'm curious if there's a better way.

Thanks,
-KF

Nov 19 '05 #3
the rendered output is just a i/o stream of the html content. you can do
anything you want to it, but you would have to reparse it.

the preRender event is the last change to modifiy in the memory model of the
"parsed" page. only items with a runat=server are parsed into the tree,
everty thiong between server objects is parsed as a literal

image the following html:

<html>
<head>
<link id=link1 runat=server href="foo.css" \>
</head>
<body>
<span id=span1 runat=server><f ont size=1>hi</font></span>
</body>
</html>

is parsed into 5 controls

l1 = new LiteralControl( "<html>\n<head> \n");

link1 = new HtmlGenericCont rol("link");
link1.ID = "link1"
link1.Attribute s.Add("href","f oo.css");

l2 = new LiteralControl( "</head>\n<body>") ;

span1 = new HtmlGenericCont rol("span");
span1.ID = "span1";
span1.InnerHtml = "<font size=1>hi</font>";

l3 = new LiteralControl( "</body>\n</head>");

these five controls will be added to the pages Controls collection.

-- bruce (sqlwork.com)
<ke*****@u.wash ington.edu> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
ASP.NET is a kind of "engine" that takes declarative markup and code and
renders these instructions into presentational forms. And every page is a
class.

With that in mind I'm wondering,

a) how to intercept the rendered output and do further programmatic things
with it;
and
b) how coarse or finely grained the control might be. One could envision
the ASP.NET designers giving you programmatic access to subselections of
the page HTML (e.g. <head> ... </head> <body> ... </body> ). Maybe even
a page hieararchy.

I'm interested in rendering content into various non-HTML forms (pdf,
Flash text, multipart mails) and I'd like the ASP.NET engine to do the
hard work of preprocessing some of this content; these ideas are
especially interesting with the availability of skins, themes, and master
pages in asp.net 2.0.

Barring programmatic access, I suppose I can yank what I want using
regular expressions, but I'm curious if there's a better way.

Thanks,
-KF

Nov 19 '05 #4
In ASP.NET 2.0 this can be done with the new Adapter rendering model. It's
intended to allow external code (the "adapter") control rendering when there
is an alternate client being used (such as a handheld device).

-Brock
DevelopMentor
http://staff.develop.com/ballen
ASP.NET is a kind of "engine" that takes declarative markup and code
and renders these instructions into presentational forms. And every
page is a class.

With that in mind I'm wondering,

a) how to intercept the rendered output and do further programmatic
things
with it;
and
b) how coarse or finely grained the control might be. One could
envision the
ASP.NET designers giving you programmatic access to subselections of
the
page HTML (e.g. <head> ... </head> <body> ... </body> ). Maybe even
a page
hieararchy.
I'm interested in rendering content into various non-HTML forms (pdf,
Flash text, multipart mails) and I'd like the ASP.NET engine to do the
hard work of preprocessing some of this content; these ideas are
especially interesting with the availability of skins, themes, and
master pages in asp.net 2.0.

Barring programmatic access, I suppose I can yank what I want using
regular expressions, but I'm curious if there's a better way.

Thanks,
-KF


Nov 19 '05 #5

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

Similar topics

6
1787
by: Valery Polyakov | last post by:
I am drawing lines with a semi-transparent color (alpha=100). When these lines intercept, the color becomes more intense. Is there a way to avoid this, so that I would get the same intensity of color? Thanks a lot.
7
4084
by: John | last post by:
Hi, Can anyone point me out how to intercept the keystrokes from a c# application that's not a active window? - intercepting the system wide keystrokes before it hits the target active window? Thanks! John
0
1699
by: VMI | last post by:
My Windows datagrid has two columns: one with the data that the user will see (col_X) and the other one (a hidden one: col_sort) that'll be used to sort data. When a user clicks on col_X's column header, I'm intercepting the header click and "telling" it to sort the dataview using col_sort. But for some reason, the "return" is not being...
3
2042
by: Jason Honn | last post by:
I have an .aspx page that renders fine in IE6, but it does not render properly in Firefox. If I change the extension from .aspx to .htm everything renders just fine in Firefox. The problem I am having deals with stretching nested tables to fill the cell they are nested in completely. I have specified the embedded table to have a height of...
4
3938
by: Curious Coder | last post by:
I have been tasked with a project that I do not think can be accomplished. Our company has an application that runs as an unmanaged ActiveX control on user desktops. It is designed to work with our phone system. When a phone call comes in, users can click a button on the ActiveX control and begin recording. My task is to fire off this...
5
16250
by: aaa | last post by:
Is there a simple straight forward tool out there for intercepting my SOAP requests so that I can debug the XML that I am sending?
6
1943
by: dpomt | last post by:
I have a quite strange problem with the Menu control. I have ten languages and each language has a SiteMapDataSource and a Menu. For better performance, I am creating a hashtable (language -> (Menu, SitemapDataSource)) and holding this hashtable in the Cache object. On each page request, I am inserting the menu corresponding to the specified...
1
5020
by: jason.m.ho | last post by:
Has anyone run into the problem of firefox 'border-collapse: collapse' rendering a table 1-pixel too far to the left? In IE and Opera it will render fine...Does anyone know if this is a bug? This property only holds true in standards compliance mode (quirks mode firefox renders it fine). For example, if you had the following code: <!DOCTYPE...
12
4207
by: M.L. | last post by:
When loaded from my hard drive, the webpage I'm working on renders fine on IE6, Firefox 2.0.0.1, and Opera 9.02. However, after uploading it to the web there are 2 images that fail to display on those browsers. All the other images and everything else on the page render just fine. 1.) I converted one of the gif images to a jpeg but that made...
0
1043
by: Gabriel Genellina | last post by:
En Thu, 18 Sep 2008 19:24:26 -0300, Robert Dailey <rcdailey@gmail.com> escribió: Why don't you try it yourself? You may replace builtins.print with your own function too. It's not exactly the same thing, but given your request "intercepting things send to print() before they're sent to sys.stdout" it may be more adequate. --
0
7512
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.