input id attribute

N

Neil Zanella

Hello,

The book "Programming ASP.NET" by O'Reilly, an excellent source of ASP.NET
information indeed, specifies that along with the runat="server" attribute
an id attribute should also be specified in order to make use of variable
names. However, the XHTML specification found at the following site:
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
does not state anything regarding an id attribute. Despite this fact,
Web Matrix is outputting an id attribute to web clients. Furthermore,
the ASP.NET book mentions nothing about the name attribute (which is
required according to the spec, given below). The name and id attributes
are both output to the client, but isn't the id attribute redundant,
given that the name attribute is already there?

Thank you for your feedback,

Neil

The XHTML spec states the following as part of its DTD:

<!-- the name attribute is required for all but submit & reset -->

<!ELEMENT input EMPTY> <!-- form control -->
<!ATTLIST input
%attrs;
%focus;
type %InputType; "text"
name CDATA #IMPLIED
value CDATA #IMPLIED
checked (checked) #IMPLIED
disabled (disabled) #IMPLIED
readonly (readonly) #IMPLIED
size CDATA #IMPLIED
maxlength %Number; #IMPLIED
src %URI; #IMPLIED
alt CDATA #IMPLIED
usemap %URI; #IMPLIED
onselect %Script; #IMPLIED
onchange %Script; #IMPLIED
accept %ContentTypes; #IMPLIED
align %ImgAlign; #IMPLIED
 
G

Guest

Hi,

You must give the id attribute, if you want to access it from the code in
ASP.NET. ID and Name attribute can be same for a given control. You can
access the control in client side javascript using its name.

Prakash.C
 
N

nzanella

Hello,

Thank you for your reply. I see a problem though with id because it
is also used for rendering with CSS. With id used for CSS several
distinct table elements or other elements may use the same id in
order to render in the same way despite the fact that they are
different objects and as such would require different id values
in ASP.NET.

Thank you for your feedback,

Neil
 

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

Top