473,508 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

id vs. name attribute for Html controls

Joe
Hello All:

Does anyone know the difference between the name and id attributes in an
Html control? I noticed on PostBack that I can not retrieve the
Request.Form("id_value") but I can retrieve the Request.From("name_value").

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Dec 8 '05 #1
6 2739
You just get it IMO. My understanding is that "id" is the client side name
for scripting elements (whatever element you are using) while the "name" is
the name used server side for submitted values (for example in 2.0 you have
no more the "name" attribute for a form as the form itself doesn't have a
name server side).
--
Patrice

"Joe" <jo******@donotspam.yahoo.com> a écrit dans le message de
news:07**********************************@microsof t.com...
Hello All:

Does anyone know the difference between the name and id attributes in an
Html control? I noticed on PostBack that I can not retrieve the
Request.Form("id_value") but I can retrieve the Request.From("name_value").
TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Dec 8 '05 #2
It isn't an ASP.Net issue, it's simply how HTML works. When you POST a
form, the HTML specification mandate that the data be posted in the shape of
NAME=VALUE&NAME1=VALUE1&NAME2=VALUE2

It's just how html works.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:07**********************************@microsof t.com...
Hello All:

Does anyone know the difference between the name and id attributes in an
Html control? I noticed on PostBack that I can not retrieve the
Request.Form("id_value") but I can retrieve the
Request.From("name_value").

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Dec 8 '05 #3
Joe
Thanks Karl,

So, what is the id attribute for?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Karl Seguin" wrote:
It isn't an ASP.Net issue, it's simply how HTML works. When you POST a
form, the HTML specification mandate that the data be posted in the shape of
NAME=VALUE&NAME1=VALUE1&NAME2=VALUE2

It's just how html works.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:07**********************************@microsof t.com...
Hello All:

Does anyone know the difference between the name and id attributes in an
Html control? I noticed on PostBack that I can not retrieve the
Request.Form("id_value") but I can retrieve the
Request.From("name_value").

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Dec 8 '05 #4
Id is used in the document object model (DOM) of the page. In other words,
it's chiefly used with javascript. Name attributes musn't be unique, which
you often see when using radio's or checkboxes (groups all share the same
name). Id's should be.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:BC**********************************@microsof t.com...
Thanks Karl,

So, what is the id attribute for?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Karl Seguin" wrote:
It isn't an ASP.Net issue, it's simply how HTML works. When you POST a
form, the HTML specification mandate that the data be posted in the shape
of
NAME=VALUE&NAME1=VALUE1&NAME2=VALUE2

It's just how html works.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:07**********************************@microsof t.com...
> Hello All:
>
> Does anyone know the difference between the name and id attributes in
> an
> Html control? I noticed on PostBack that I can not retrieve the
> Request.Form("id_value") but I can retrieve the
> Request.From("name_value").
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Dec 8 '05 #5
Joe
Thanks Karl. This helps.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Karl Seguin" wrote:
Id is used in the document object model (DOM) of the page. In other words,
it's chiefly used with javascript. Name attributes musn't be unique, which
you often see when using radio's or checkboxes (groups all share the same
name). Id's should be.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:BC**********************************@microsof t.com...
Thanks Karl,

So, what is the id attribute for?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Karl Seguin" wrote:
It isn't an ASP.Net issue, it's simply how HTML works. When you POST a
form, the HTML specification mandate that the data be posted in the shape
of
NAME=VALUE&NAME1=VALUE1&NAME2=VALUE2

It's just how html works.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:07**********************************@microsof t.com...
> Hello All:
>
> Does anyone know the difference between the name and id attributes in
> an
> Html control? I noticed on PostBack that I can not retrieve the
> Request.Form("id_value") but I can retrieve the
> Request.From("name_value").
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Dec 8 '05 #6
this is partially correct.

the name attribute is only valid on the <form> and form elements
(<input>,<textarea> and <select>). it used to specify the name to assoicate
with the name/value pair that is submitted on a form post.

for example:

<input type=checkbox name=foo value=1>

if checked will submit foo=1. in the dom you can reference form elements
from the form.elements collection by specifing the name as the index. if is
not unique, the collection returns an array of elements rather than the
element. modern dom's support looking up form elements by name as:

document.getElementsByName(nameValue)

note: it always returns an array even if only one element is found.
id attribute is from the xml world, and is a unique id for any node, not
just form elements. unlike the name attribute it is valid on any html node.
also like the name attribute, it must follow the valid identitfier rules.
the identitfer should start with an alpha, and only contain alpha
([a-zA-Z]), numbers, hyphen, underscore and colons.(note aspnet breaks this
rule by starting reserved ids with a underscore - thus they will alway fail
an html/xml lint - actually some proxies strip them). to find any html
element by id you use:

document.getElementById(idvalue)

this only returns one dom node.

-- bruce (sqlwork.com)



"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Id is used in the document object model (DOM) of the page. In other
words, it's chiefly used with javascript. Name attributes musn't be
unique, which you often see when using radio's or checkboxes (groups all
share the same name). Id's should be.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:BC**********************************@microsof t.com...
Thanks Karl,

So, what is the id attribute for?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Karl Seguin" wrote:
It isn't an ASP.Net issue, it's simply how HTML works. When you POST a
form, the HTML specification mandate that the data be posted in the
shape of
NAME=VALUE&NAME1=VALUE1&NAME2=VALUE2

It's just how html works.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:07**********************************@microsof t.com...
> Hello All:
>
> Does anyone know the difference between the name and id attributes in
> an
> Html control? I noticed on PostBack that I can not retrieve the
> Request.Form("id_value") but I can retrieve the
> Request.From("name_value").
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Dec 8 '05 #7

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

Similar topics

9
6999
by: Ton den Hartog | last post by:
I am confused, when use ID and when use NAME to identify an element in HTML ? Ton den Hartog -- Computer museum tonh: http://www.tonh.net - 10.000 visitors !! GGGallery website...
9
6034
by: aragon | last post by:
Hi all, is it legal to use a fully-numeric string as "name" attribute for the <select> tag in the XHTML standard? E.g.: <form action="action.php" method="get"> <select name="12345"> <option...
1
2164
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
24
2479
by: Chameleon | last post by:
This code does not working in Mozilla. Works fine in IE. -------------- <input type=text value=100 name=textbox> <script> alert(textbox); </script> -------------- This perhaps, because of...
1
1063
by: Nathan Sokalski | last post by:
As most of us probably know, ASP.NET controls do not use an exact copy of a control's ID for the HTML element's name or id attribute. When generating JavaScript as part of a control or event, we...
11
5811
by: Jasbird | last post by:
Has the name attribute deprecated? I ask this because ASP.NET 2 warns me against using it, says that it has been deprecated and doesn't use it (on the client) when creating a radio button list....
6
2282
by: Dick Watson | last post by:
I had a page that works when setup like this: === <form name="frmCalc" action=""> <script type="text/javascript"> function btnCalc_onclick(abc) { return "got here with " + abc; }
4
1245
by: TS | last post by:
i am wondering why the name of the controls are listed in parameters of request object instead of ID. The name always uses the default '$' for encapsulations and the ID uses '_'. When i use...
11
1864
by: CJM | last post by:
I have a bit of code that inserts some extra controls (specifically, ordinary <input type="hidden" name="MyField"form fields) into an existing HTML form. However, it is mangling the name & IDs of...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.