asp.net 1.1 generates spurious whitespace

A

ajfish

hi,

I have an asp.net webform that contains some source like this

<img src="..."><asp:hyperlink id=".." runat="server"...>

with no whitespace between the tags. when the page is rendered, it
comes out like this:

<img src="..."> <asp:hyperlink id=".." runat="server"...>

there are 2 tab characters between the end of the img tag and the
hyperlink tag which cause a space to appear where I don't want it in
the HTML.

I have this exact sequence repeated in many places in the application
(several times on the same page) and there are 2 that behave in this
way, but I can't find any rhyme nor reason for it. there is no funny
character in the source file.

anyone else seen this problem? any ideas for a workaround?

Andy
 
M

Mike Hofer

hi,

I have an asp.net webform that contains some source like this

<img src="..."><asp:hyperlink id=".." runat="server"...>

with no whitespace between the tags. when the page is rendered, it
comes out like this:

<img src="..."> <asp:hyperlink id=".." runat="server"...>

there are 2 tab characters between the end of the img tag and the
hyperlink tag which cause a space to appear where I don't want it in
the HTML.

I have this exact sequence repeated in many places in the application
(several times on the same page) and there are 2 that behave in this
way, but I can't find any rhyme nor reason for it. there is no funny
character in the source file.

anyone else seen this problem? any ideas for a workaround?

Andy

It's not ASP.NET 1.1 that's the culprit. It's your editor (likely
Visual Studio .NET 2002 or 2003). Both versions of Visual Studio are
notorious for mangling your HTML into what *they* want it to look
like, regardless of your best efforts to make it look the way *you*
want it.

It's a constant source of frustration.

In the end, however, unless the end-users are going to view the HTML,
or you're generating HTML to be parsed by a nitpicking parser that
can't handle the extraneous whitespace, the layout shouldn't matter.
It's an annoyance, and nothing more.
 
M

Mike Hofer

hi,

I have an asp.net webform that contains some source like this

<img src="..."><asp:hyperlink id=".." runat="server"...>

with no whitespace between the tags. when the page is rendered, it
comes out like this:

<img src="..."> <asp:hyperlink id=".." runat="server"...>

there are 2 tab characters between the end of the img tag and the
hyperlink tag which cause a space to appear where I don't want it in
the HTML.

I have this exact sequence repeated in many places in the application
(several times on the same page) and there are 2 that behave in this
way, but I can't find any rhyme nor reason for it. there is no funny
character in the source file.

anyone else seen this problem? any ideas for a workaround?

Andy

Completely ignore my previous post. I totally misunderstood your post.
(Not enough coffee yet. It's not 6 PM yet.)

I *have* seen this issue before, and it's a bummer. I'm not sure what
I did to get around it. Have you tried cutting the page's HTML out and
pasting it into Notepad, then clearing the document, and repasting the
HTML?

There might be a control character embedded in the document that you
just can't see. (A smart tag or something stupid.)
 
A

ajfish

ok, I have found a workaround

just above the offending tags I put this:

<span runat=server visible=false></span>

I've no idea how it works (and don't ask how much trial and error was
involved to discover it)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,006
Latest member
LauraSkx64

Latest Threads

Top