473,657 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alter Rendered HTML for page

I'm trying to implement XHTML standards in my ASP.NET web pages but
whenever I use web controls I get problems because of the very strict
nature of W3C XHTML (transitional version is picky but strict1.1 very
severe!)

e.g. align="Center" fails validation because of the capital "C" - this
makes asp:Calendar control unuseable because it happens to use this
tag for each of the cells. Also Javascript tags require a 'type'
attribute...etc

My question is - is there a generic event that would allow me to
'intercept' the rendered html and manipulate it so these standards can
be met?

P.S. I admit that the best answer would be for Microsoft to include
DTD selection options for the HTML produced from web forms pages.
Visual Studio 2002 only allows HTML 4.0 Transitional and that's what
I'm using - can't say I'm not (very) disappointed either.

Microsoft staff please take note! I work for the UK government and
XHTML forms part of their e-government standards. There is a lot of
business to be gained by making XHTML output part of ASP.NET - think
accessibiity - all for the sake of a few inconsistencies in case
etc...
Nov 17 '05 #1
7 3676
Can arbitrary HTML be reliably translated into XHTML?

I would question whether you're going to have general success in making a
non-XHTML toolset comply with standards it doesn't understand. I would think
that it would be more effective for the British Government to simply dump
ASP.NET and send a nice letter to Microsoft telling them how much business
they just lost. You could then spend your time developing applications for
toolsets which actually care what your requirements are.

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
"Kersh" <ia*********@hy ndburnbc.gov.uk > wrote in message
news:64******** *************** ***@posting.goo gle.com...
I'm trying to implement XHTML standards in my ASP.NET web pages but
whenever I use web controls I get problems because of the very strict
nature of W3C XHTML (transitional version is picky but strict1.1 very
severe!)

e.g. align="Center" fails validation because of the capital "C" - this
makes asp:Calendar control unuseable because it happens to use this
tag for each of the cells. Also Javascript tags require a 'type'
attribute...etc

My question is - is there a generic event that would allow me to
'intercept' the rendered html and manipulate it so these standards can
be met?

P.S. I admit that the best answer would be for Microsoft to include
DTD selection options for the HTML produced from web forms pages.
Visual Studio 2002 only allows HTML 4.0 Transitional and that's what
I'm using - can't say I'm not (very) disappointed either.

Microsoft staff please take note! I work for the UK government and
XHTML forms part of their e-government standards. There is a lot of
business to be gained by making XHTML output part of ASP.NET - think
accessibiity - all for the sake of a few inconsistencies in case
etc...

Nov 17 '05 #2
Hmmm...thanks for replying John but not very useful comment
unfortunately.

The HTML I am transforming is not arbitrary - ASP.NET still produces
good HTML and the aspx page is still designed by myself - hence could
hardly be described as "arbitrary" - it's 98% XHTML - just happens to
contain some server control rendered attributes & tags that are
invalid.

I just need to tweak a few common tags/attributes I'm finding
(align="Center" , type="text/css" etc). If I can intercept the HTML at
an event like page_prerender I can easily write a component to
validate the HTML output. The problem is that it would have to
encapsulate the entire page's HTML not just that of the individual
controls - because there are things like <script> tags that need
modifying that are inserted to facilitate the postbacks...

ASP.NET is the best tool available for our requirements (fast, neat,
scalable, re-useable development.) Try to remember that server
controls are only a small part of this technology - even if I never
use them I'd still be using ASP.NET - but I anticipate and hope for
the ability to implement multiple DTD's up to XHTML strict 1.1 as part
of the next framework release.

Any answers containing some useful code?

"John Saunders" <jo***********@ surfcontrol.com > wrote in message news:<ua******* *******@TK2MSFT NGP09.phx.gbl>. ..
Can arbitrary HTML be reliably translated into XHTML?

I would question whether you're going to have general success in making a
non-XHTML toolset comply with standards it doesn't understand. I would think
that it would be more effective for the British Government to simply dump
ASP.NET and send a nice letter to Microsoft telling them how much business
they just lost. You could then spend your time developing applications for
toolsets which actually care what your requirements are.

Nov 17 '05 #3
Keith, if your ASP.NET page contains arbitrary Server Controls, then it will
generate arbitrary HTML. A control can generate whatever HTML it likes -
ASP.NET has no say in the matter.

Also, if you need to translate some small, fixed number of ASP.NET pages
which you are designing, then I'm sure you can do the translation. But if
others are working on the project, or if the project has more than a few
pages or exists over more than a short span of time, then you will rapidly
approach "arbitrary" .

Also, to the extent that you are not the person controlling the HTML to be
translated, then you will not have control over when the generator of that
HTML should decide to change the details of how it's generated. You'll be in
the same position as some programmers I've met who wrote code which depended
on the precise text of an error message generated by another piece of code,
and who were disappointed when the error message changed to use proper
grammar.

It's because of things like these that I asked whether there was some
general algorithm for translating valid HTML into valid XHTML. It seems to
me that only such an algorithm will succeed in the long run.

Also, it sounds to me as though you are at the beginning of a process which
may involve you using your translator for the next three years or so - until
you can deploy the hypothetical version of ASP.NET which is fully XHTML
compliant, along with compliant versions of all of the controls used by all
of your pages. Keep in mind that compliance to your requirements may perhaps
not be achieved in version 2.0 of ASP.NET, even if it _is_ an obvious
feature to include in a 2.0 release. Talk to someone about Microsoft Visual
C++ and how one is always waiting for the "next release" for full standards
compliance.

My recommendation about the Government clearly indicating their requirements
to Microsoft ( ;-) ) were not entirely facetious. Given what I perceive as
the likely course you're about to embark upon (making someone else's code do
something they never intended that it should do), I thought that it may be
early enough in Microsoft's development cycle that forceful action could
cause them to actually meet your requirements in the 2.0 timeframe. "I can't
use your product and so won't be buying any" is more likely to cause the
desired reaction than "I can use your product, but only with this workaround
I've written and maintain, and we'll be buying it anyway, so you needn't
lose sleep over it".

BTW, you say that this is a UK standard, but I wonder if there are similar
EU standards? Collective action might be even more effective.

Any answers containing some useful code?
Oh, you wanted code, did you? :-)

Well, before I go into code, I'll quickly mention that the "political"
solutions I discussed might be effective in causing Microsoft to give you a
supported solution to your problem in addition to focusing their attention
on the issue for the 2.0 release. It might also put you in continued contact
with a person at Microsoft who may act as a conduit into Microsoft for your
concerns on this matter. In other words, you might require them to provide
you with a workaround as a condition of purchase.

You have a few choices given the appropriate translation algorithm. You can
derive all of your pages from a single base class, which itself derives from
System.Web.UI.P age. This class would override the Render method:

/// <summary>
/// Render - override to modify the output of a derived page
/// </summary>
/// <param name="writer">T he HtmlTextWriter to send the output
to</param>
protected override void Render(HtmlText Writer writer)
{
System.IO.Strin gWriter sw = new System.IO.Strin gWriter();
HtmlTextWriter localWriter = new HtmlTextWriter( sw);
base.Render(loc alWriter);

string output = sw.ToString();

// Do what you like with the output
output = output.ToUpper( );

writer.Write(ou tput);
}

The other option involves using Response.Filter . Replace that with a stream
of your choice to modify the output as it comes out. That will be less
convenient to program for your needs, since the output does not come out all
at once.

Good Luck,
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

P.S. Out of curiosity and self-interest, I wonder: with which version of the
XHTML standard does the UK Government require compliance? Since I work at a
UK-based company creating web sites, this might become interesting to me.
"Kersh" <ia*********@hy ndburnbc.gov.uk > wrote in message
news:64******** *************** ***@posting.goo gle.com... Hmmm...thanks for replying John but not very useful comment
unfortunately.

The HTML I am transforming is not arbitrary - ASP.NET still produces
good HTML and the aspx page is still designed by myself - hence could
hardly be described as "arbitrary" - it's 98% XHTML - just happens to
contain some server control rendered attributes & tags that are
invalid.

I just need to tweak a few common tags/attributes I'm finding
(align="Center" , type="text/css" etc). If I can intercept the HTML at
an event like page_prerender I can easily write a component to
validate the HTML output. The problem is that it would have to
encapsulate the entire page's HTML not just that of the individual
controls - because there are things like <script> tags that need
modifying that are inserted to facilitate the postbacks...

ASP.NET is the best tool available for our requirements (fast, neat,
scalable, re-useable development.) Try to remember that server
controls are only a small part of this technology - even if I never
use them I'd still be using ASP.NET - but I anticipate and hope for
the ability to implement multiple DTD's up to XHTML strict 1.1 as part
of the next framework release.

Any answers containing some useful code?

"John Saunders" <jo***********@ surfcontrol.com > wrote in message

news:<ua******* *******@TK2MSFT NGP09.phx.gbl>. ..
Can arbitrary HTML be reliably translated into XHTML?

I would question whether you're going to have general success in making a non-XHTML toolset comply with standards it doesn't understand. I would think that it would be more effective for the British Government to simply dump ASP.NET and send a nice letter to Microsoft telling them how much business they just lost. You could then spend your time developing applications for toolsets which actually care what your requirements are.

Nov 17 '05 #4
Firstly, it's Kersh - not Keith.
It's a nickname. My Surname is 'Kershaw'.

OK dude. I didn't want to get into a discussion. You don't know how to
alter the HTML output from Server Controls in an ASP.NET page? That's
OK then.

I don't have time for a crusade to get Microsoft to standardise the
output of ASP.NET WebControls to XHTML. We simply live in hope.

And here's the definition of Arbitrary for you:
Determined by chance, whim, or impulse, and not by necessity, reason,
or principle: stopped at the first motel we passed, an arbitrary
choice.

ALL my HTML AND ASP.NET server controls are inserted by a team working
to the same XHTML principles, and we have examined the controls to
determine exactly which ones will produce me a few non-XHTML
tags/attributes and which won't. NOTHING chance, random, or impulsive
about that mate, it's all cause, effect, & logic. I.e. NON-ARBITRARY
no matter how many pages & controls I develop, because we work to
standards and procedures.

NO RANDOM FACTORS in there at all. I can also clearly identify 5-6
modifications to the HTML produced by them that would make ANY GENERIC
PAGE that uses these controls XHTML compliant. So if there isn't an
algorithm, I'm going to write a basic version of it.

OK - maybe I'd have to modify the algorithm if I upgraded to ASP.NET
2.0, but I'll do that when I come to it. As for your error text
example - don't take me for a total amateur - I would be writing a
sort of crude but generic XHTML parser - but it would never be that
idiotic!

To be honest John I'd quite like an answer - not a lecture about why I
shouldn't be asking the question. But you don't have an answer for me,
do you?
Nov 17 '05 #5
Kersh,

Did you notice that my most recent post included some code in answer to your
question?

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
"Kersh" <ia*********@hy ndburnbc.gov.uk > wrote in message
news:64******** *************** ***@posting.goo gle.com...
Firstly, it's Kersh - not Keith.
It's a nickname. My Surname is 'Kershaw'.

OK dude. I didn't want to get into a discussion. You don't know how to
alter the HTML output from Server Controls in an ASP.NET page? That's
OK then.

I don't have time for a crusade to get Microsoft to standardise the
output of ASP.NET WebControls to XHTML. We simply live in hope.

And here's the definition of Arbitrary for you:
Determined by chance, whim, or impulse, and not by necessity, reason,
or principle: stopped at the first motel we passed, an arbitrary
choice.

ALL my HTML AND ASP.NET server controls are inserted by a team working
to the same XHTML principles, and we have examined the controls to
determine exactly which ones will produce me a few non-XHTML
tags/attributes and which won't. NOTHING chance, random, or impulsive
about that mate, it's all cause, effect, & logic. I.e. NON-ARBITRARY
no matter how many pages & controls I develop, because we work to
standards and procedures.

NO RANDOM FACTORS in there at all. I can also clearly identify 5-6
modifications to the HTML produced by them that would make ANY GENERIC
PAGE that uses these controls XHTML compliant. So if there isn't an
algorithm, I'm going to write a basic version of it.

OK - maybe I'd have to modify the algorithm if I upgraded to ASP.NET
2.0, but I'll do that when I come to it. As for your error text
example - don't take me for a total amateur - I would be writing a
sort of crude but generic XHTML parser - but it would never be that
idiotic!

To be honest John I'd quite like an answer - not a lecture about why I
shouldn't be asking the question. But you don't have an answer for me,
do you?

Nov 17 '05 #6
No I didn't John. But I will test it out and I'm sure it will work
fine.
Apologies for my ramblings there - especially seeing as you had an
answer for me. I was in the wrong on that one - although I still feel
I know when to use the word arbitrary if you fancy throwing a
dictionary at me!

The UK government advocate adoption of XHTML standards generally as
part of it's E-gif (interoperabili ty framework) - therefore mostly
XHTML 1.0 transitional will do - although many local government
organisations seem not to be able to do what they want under the
restrictions demanded by XHTML and so they ignore the standards.

Once example would be the APLAWS project (Accessible and Personalised
Local Government Websites http://www.aplaws.org.uk). This is supposed
to supply software to run sites according to XHTML & accessibility
guidelines supplied by the RNIB, Bobby and W3C but unfortunately
drastically fails to meet any of them. (It is also ludicrously
difficult to install, setup, use, and manage. We got a working example
running but had to abandon it because everyone who used it from a
technical prespective or not found it a nightmare. My theory is that
there's a few London Borough Councillors with shares in Red Hat Linux
and Oracle!)

However, I feel that these standards should be adhered to and so will
do so with all my webpages, with a little help from you John and my
XHTML checking algorithm...

If you want to read more check out the website of the deputy prime
minister, the IDeA, or search for E-gif standards.
Nov 17 '05 #7
Thanks for the response, Kersh.

I'll check out the references you provided. I've been very concerned once I
heard about governments demanding adherence to incomplete standards.

And, BTW, I was dead serious about how to get MS to actually adhere to the
(eventual) standard, especially considering how the EU anti-trust people
feel about them
(http://news.com.com/2100-1016_3-5060...ag=fd_nbs_ent).
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

"Kersh" <ia*********@hy ndburnbc.gov.uk > wrote in message
news:64******** *************** ***@posting.goo gle.com...
No I didn't John. But I will test it out and I'm sure it will work
fine.
Apologies for my ramblings there - especially seeing as you had an
answer for me. I was in the wrong on that one - although I still feel
I know when to use the word arbitrary if you fancy throwing a
dictionary at me!

The UK government advocate adoption of XHTML standards generally as
part of it's E-gif (interoperabili ty framework) - therefore mostly
XHTML 1.0 transitional will do - although many local government
organisations seem not to be able to do what they want under the
restrictions demanded by XHTML and so they ignore the standards.

Once example would be the APLAWS project (Accessible and Personalised
Local Government Websites http://www.aplaws.org.uk). This is supposed
to supply software to run sites according to XHTML & accessibility
guidelines supplied by the RNIB, Bobby and W3C but unfortunately
drastically fails to meet any of them. (It is also ludicrously
difficult to install, setup, use, and manage. We got a working example
running but had to abandon it because everyone who used it from a
technical prespective or not found it a nightmare. My theory is that
there's a few London Borough Councillors with shares in Red Hat Linux
and Oracle!)

However, I feel that these standards should be adhered to and so will
do so with all my webpages, with a little help from you John and my
XHTML checking algorithm...

If you want to read more check out the website of the deputy prime
minister, the IDeA, or search for E-gif standards.

Nov 17 '05 #8

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

Similar topics

3
3847
by: usenet | last post by:
Hi All, I have some initialization to be done at page load time, which changes the text of some anchors so that they are consistent with the query string (these anchors are used as criteria selectors, and should be initialized to the criteria contained within the url). IE and Safari fire the onload event before rendering any elements, so when the event handler synchronizes the anchors, they are rendered with the right contents...
2
3963
by: Stephen Miller | last post by:
I have an ASPX report and I want to capture the rendered HTML and write to a file on the webserver. Several posts suggest using WebRequest to make a second call to the page, and screen-scrape the resulting HTML. The technique typically described is: '-- Get the current URL and request page Dim url As String = System.Web.HttpContext.Current.Request.Url.AbsoluteUri Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url)
1
1119
by: SlimFlem | last post by:
I hope this makes sense. Here is what I am attempting. I have an inital generic aspx page that has one custom tag: <web:site id=webSite runat=server/> When this control evaluates, it will return a small amount of Html with another custom control tag inside this html. For example:
2
1776
by: Patient Guy | last post by:
I don't think I have ever encountered something like this before. On a Windows XP running Apache 2.0.53 I do my page development (XP machine). I then upload the stuff to a Linux/Redhat/Fedora running Apache 2.0.54 (Linux machine) I have a page that features an external stylesheet, as well as styling in the <style> element area of the document head, as well as element-specific
6
1253
by: Ray Booysen | last post by:
Hi All In my ASP.NET project, all my pages inherit from a base class which extends the Page object. I also have a pdf generator that takes in HTML Text and will generate a PDF for you. What I want to implement in my custom Page class is the ability for the page to generate the HTML text of itself. Can this be done? I have tried looping through all my controls and rendering them as per your example but am hitting some walls. Any...
5
1353
by: homertbush | last post by:
When our asp.net pages are rendered out as html the page directive is still in the html. ie. The following page directive is present in the body of the html of the rendered page: <%@ Page CodeBehind="about.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Briggs.about" %> <%@ Register TagPrefix="uc1" TagName="WebUserControlSearch" Src="WebUserControlSearch.ascx" %>
3
1480
by: funstercinsolata | last post by:
--- This is my simple default.aspx: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
6
2370
by: amaragraps | last post by:
Dear thescripts Experts, I have converted my large wavelets page http://www.amara.com/current/wavelet.html from HTML into XHTML and CSS and have one large remaining bug. On Safari and Opera and the Linux Red Hat browser, the full page is not rendered, even though if you "view" the source in the browser window, all of the text is listed.
2
1510
by: Brian Simmons | last post by:
Hi, Long story short: I've got a website built, and we moved it over to the production server, which is an SSL-required (https://...) server. A third party component that I'm using makes use of an <iframe>. Unfortunately they set the SRC attribute to "". This causes Internet Explorer to display a message box dialog warning about this page contains non-secure and secure items, do you wish to display the non-secure items, Y/N?
0
8397
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8503
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4158
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1620
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.