control name change in asp.net 2.0 generated html

N

n33470

Hi all,

We have a user control that contains a DropDownList. This user
control appears on a web page. Suppose the name of the userControl on
the web page is called "ucLookup". Suppose the name of the
dropDownList within the user control is called "cboList".

On my development PC running VS2005 on WinXP Pro, the rendered HTML for
the dropDownList looks like this:

<select name="ucLookup:cboList" id="ucLookup_cboList"
class="cboBodyNormal">

Notice that the name attribute contains a ':' (colon) between the
userControl name and the dropdownlist name.

On a production server running Windows Server 2003 and the .NET
framework installed from the redistributable, rather than from VS2005
(but still running the 2.0.50727 version), the rendered HTML is this:

<select name="ucLookup$cboList" id="ucLookup_cboList"
class="cboBodyNormal">

Notice now that there is '$' character in the name of the control.
Between the two environments, the only major difference I can think is
the OS (WinXP Pro vs Windows Server 2003), and that the .NET framework
on Windows Server box was installed from the redistributable, rather
than from VS2005

Has anyone noticed this before? Is there any kind of environment
setting that controls the separater character which is used here?

--steve
 
K

Karl Seguin

Steve:
I dung into it for you using reflector (you should try it out) and came to
this:

internal char IdSeparatorFromConfig
{
get
{
if (!this.EnableLegacyRendering)
{
return '$';
}
return ':';
}
}

as part of the control class


EnableLegacyRendering goes deeper, not 100% sure, but it seems like it might
be (a) config driven (do a google search for it and you'll find a few posts
about it from the Beta 2 days), or based on some other page properties.

Karl
 
N

n33470

Karl,

Thanks for the info! Where is the property "EnableLegacyRendering"
implemented? In your code example, what is the context of 'this' in
the line of code: if (!this.EnableLegacyRendering)

The help docs for VS2005 do not mention this property, and there is
intellisense clue in either a derived UserControl, or Page class.

Where is that property implemented?

--steve
 
K

Karl Seguin

Steve:
My original email had all the details ;) It's an internal property of the
Control class. That's why you don't see it in the docs/intellisense and
can't access it. It's only visible through a dissassembler such as
reflector. The only way to answer these questions is to get into the guts
of stuff.

Karl
 
B

Bruce Barker

the change was done to make the names legal, colon are allowed in html
identifies but dollar signs are not. a colon in a id tags specifies a
namespace so ms uses a underscore.

it a bug in your code if you used the actual names (from viewing the source)
instead of the ClientId property to get it.

to get the 2003 behaviuor, set the XhtmlConformanceSection to legacy
(produce non-compliant xhtml)


-- bruce (sqlwork.com)
 
N

n33470

Bruce/Karl,

Thanks for the all the info!

This is not an issue with the use of ClientId, the error presented
itself as an issue with the Request.Forms variables posted back from
the web browser. Because the name attribute of the html tags is formed
differently amongst the xhtmlConformance mode settings, the posted
variable collection in Request.Forms had different contents. A
secondary issue that was corrected by this is that we have a huge
library of reusable testing scripts that do automated testing. The
automated test scripts use the rendered html for verification, and
because most of the tags rendered differently, it broke some of the
test scripts.

The following web.config setting fixed up the problems.

<xhtmlConformance mode="Legacy">

This setting was present on my development server because the ASP.NET
conversion wizard added it automatically to my web.config. However,
the setting was missing on the production server. The default
conformance mode, when there is no setting in the web.config, is
"Transitional".

Thanks again!

--steve
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top