Forum Moderators: open

Message Too Old, No Replies

Asp.Net control ID and HTML validation.

Asp adds "_" to the begining and cause my page to be invalid.

         

fischermx

4:28 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm creating a website with asp.net, I have the DTD to 4.01 strict.
When I run the HTML validator on w3c.org, it marks me all my generated controls IDs or invalid.

For example :



Line 81, column 29: value of attribute "ID" invalid: "_" cannot start a name

<div id="_ctl0__ctl0_leftColumn" class="leftColumn">

It is possible that you violated the naming convention for this attribute. For example, id and name attributes must begin with a letter, not a digit.


The bad thing is that they are soo much, that it interfers in my review of more "real" errors.

What do you usually to to avoid this?
What's the common practice?

emsaw

12:48 am on Aug 17, 2005 (gmt 0)

10+ Year Member



fischermx,

Make sure all of your controls have IDs


<Test:Grd runat="server" [b]id="test01"[/b] />

if the id is missing, it will generate a name with a leading underscore, but with a name it will generally be something like id:sub_id:_control#x:_control#y

like:


<input type="submit" name="test01:grdStores:_ctl2:_ctl0" value="Edit" />