473,382 Members | 1,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

RenderBeginTag() output not XHMTL compliant

Hi,
This is seriously driving me crazy, could anyone explain to me why
neither of these doesn't produce XHTML compliant output (it is being
called in Render() btw):

output.WriteLine("<img src=\"" + vars["{$baseUrl}"] + " />");

output.AddAttribute(HtmlTextWriterAttribute.Src,
(string)vars["{$baseUrl}"]);
output.RenderBeginTag(HtmlTextWriterTag.Img);
output.RenderEndTag();

They both produce the same output:
<img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974">

What I want is this:
<img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974" />

Is there some setting that needs to be set or anything like that?
Thanks in advance!

Best regards,
Mats Lycken
Oct 6 '06 #1
3 2606
the fragment is valid, but what is the parent element?

-- bruce (sqlwork.com)

<Ma***@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi,
This is seriously driving me crazy, could anyone explain to me why neither
of these doesn't produce XHTML compliant output (it is being called in
Render() btw):

output.WriteLine("<img src=\"" + vars["{$baseUrl}"] + " />");

output.AddAttribute(HtmlTextWriterAttribute.Src,
(string)vars["{$baseUrl}"]);
output.RenderBeginTag(HtmlTextWriterTag.Img);
output.RenderEndTag();

They both produce the same output:
<img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974">

What I want is this:
<img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974" />

Is there some setting that needs to be set or anything like that?
Thanks in advance!

Best regards,
Mats Lycken

Oct 6 '06 #2
Is "output" an HtmlTextWriter or an XhtmlTextWriter? (what it is rendering
is proper HTML but not XHTML, similar to how <inputworks)
Oct 6 '06 #3
Hello Mats,

As for the control/element rendering code, where did you call them? Are you
using these code to output some child html element in your custom webserver
control?

As for the XHTML content producing, ASP.NET 2.0 provide three Conformance
mode

**Legacy (which is similar to how markup was rendered in previous versions
of ASP.NET)

**Transitional (XHTML 1.0 Transitional)

**Strict (XHTML 1.0 Strict)

And the default one "Transitional" will help render most controls as XHTML
conformed output though it still includes a few exceptions. And if you set
the conformance mode to "Strict", it will force to page to output xhtml
content that conform to XHTML 1.0 Strict standard. You can get more
information about the ASP.NET 2.0 xhtml confromance setting in the
following MSDN reference:

#ASP.NET and XHTML
http://msdn2.microsoft.com/en-us/library/exc57y7e.aspx

for your problem here, I've just performed some test on my local side
through a custom webserver control, it seems that the output is correctly
XHTML conformed (set ASP.NET xhtml conformance as "Transitional" and use
IE6 to visit the page). Here is my test code:

==========================
protected override void RenderContents(HtmlTextWriter output)
{
output.AddAttribute("id", "divxhtml");
output.RenderBeginTag(HtmlTextWriterTag.Div);
output.WriteLine("<img
src=\"http://www.asp.net/i/www_asp_net_logo.gif\" />");

output.Write(Text );
output.AddAttribute(HtmlTextWriterAttribute.Src,
"http://www.asp.net/i/www_asp_net_logo.gif");
output.RenderBeginTag(HtmlTextWriterTag.Img);
output.RenderEndTag();
output.RenderEndTag();
}

==========================

and the web.config file just contains the following XHTML conformance
setting(the default value):

<xhtmlConformance mode="Transitional"/>
Please feel free to let me know if there is anything I missed or if you
have any other particular settings in your application.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Oct 9 '06 #4

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

Similar topics

2
by: Bradford Powers | last post by:
I'm curious how I can make Python print text in color.
3
by: Joris Gillis | last post by:
Hi everyone, I have this stylesheet: <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/>...
6
by: Edward Diener | last post by:
Does anyone know the correct naming conventions for CLS compliant code ? The doc points to a really obscure and difficult to digest document on the web about Unicode names, and I am looking for...
5
by: Martman | last post by:
First here is my goal: When a datalist is rendered to a page and you use the <itemtemplate> the datalist automatically prints a <tr> <td> start and end tags. Now this may not be too bad but I...
4
by: hph | last post by:
Okay, another trivial matter that I can't solve. I have a variable - $lastdate - that is the latest date any record in a MySQL database was updated. Its MySQL format is TIMESTAMP. If I say I...
10
by: Jim Andersen | last post by:
I have this xml-file. I want to sort it, and create a new xml-file. The result should be identical to the input except that it's sorted. <?xml version="1.0" encoding="UTF-8"?> <levelone> <child...
0
by: shapper | last post by:
Hi, I am creating a custom control and I am changing the begin tag from <spanto <div>: Public Overloads Overrides Sub RenderBeginTag(ByVal writer As HtmlTextWriter) writer.Write("<div>")
15
by: Zhang Weiwu | last post by:
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml webpage to IE as application/xml I used that trick and now every one of my xhtml webpage have following first 4 starting...
19
by: Chad | last post by:
Okay, let's say I have an exotic os that limits how much goes to stdout. When I go like.. #include <stdio.h> int main(void) { int i=0; for(i=0; i< 10; i++) { printf("a \n");
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.