By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

input type="radio" ASP.net bug

P: n/a
I noticed
that using an HTMLInputRadioButton and specifying a value to be an empty
string (""), this is overridden by ASP.Net which set the value of the
control to be the same as the ID of the control.

See the code below

* Page.aspx:
<%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false"
Inherits="Webspace.Test" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<input type="radio" runat="server" name="RadioButtons" id="Button1"
value="1">Yes
<input type="radio" runat="server" name="RadioButtons" id="Button2"
value=""> No

</body>
</html>

* Page.aspx.cs
using System;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace Webspace
{
/// <summary>
/// Asp.Net bug demonstration
/// </summary>
public class Test : System.Web.UI.Page
{
protected HtmlInputRadioButton Button1;
protected HtmlInputRadioButton Button2;

private void Page_Load(object sender, System.EventArgs e)
{
}
}
}

this generates:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<input value="1" name="RadioButtons" id="Button1" type="radio" />Yes
<input value="Button2" name="RadioButtons" id="Button2" type="radio" /> No

</body>
</html>

I consider this to be a bug, although it may be by design. ASP.net is
clearly overriding a value I have specified. Has anyone else experienced
this, or have any suggestions?
Nov 19 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi David,

It is not a bug. According to http://www.ietf.org/rfc/rfc1866.txt, the
"value" attribute of an HTML radio button is required. That is, it cannot be
blank, or non-existent. This is also true of a checkbox. The reason for the
radio button's value being required is that a radio button group has a
single value, and that value is the value of the radio button in the group
that is checked. A blank string, in terms of a form POST submission, is a
non-existent value. Therefore, your value must be at least 1 character in
size. ASP.Net knows about this, and corrects it by assigning the radio
button's unique ID to the value property.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"David Cameron" <David Ca*****@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
I noticed
that using an HTMLInputRadioButton and specifying a value to be an empty
string (""), this is overridden by ASP.Net which set the value of the
control to be the same as the ID of the control.

See the code below

* Page.aspx:
<%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false"
Inherits="Webspace.Test" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<input type="radio" runat="server" name="RadioButtons" id="Button1"
value="1">Yes
<input type="radio" runat="server" name="RadioButtons" id="Button2"
value=""> No

</body>
</html>

* Page.aspx.cs
using System;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace Webspace
{
/// <summary>
/// Asp.Net bug demonstration
/// </summary>
public class Test : System.Web.UI.Page
{
protected HtmlInputRadioButton Button1;
protected HtmlInputRadioButton Button2;

private void Page_Load(object sender, System.EventArgs e)
{
}
}
}

this generates:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<input value="1" name="RadioButtons" id="Button1" type="radio" />Yes
<input value="Button2" name="RadioButtons" id="Button2" type="radio" /> No

</body>
</html>

I consider this to be a bug, although it may be by design. ASP.net is
clearly overriding a value I have specified. Has anyone else experienced
this, or have any suggestions?

Nov 19 '05 #2

P: n/a
Thanks for the reply.

After reading the RFC, it specifies that for a radio button and a checkbox
both the value and the name are required ("The NAME and VALUE attributes are
required as for check boxes"). Interestingly using the W3C online validator,
this code passes validation both with an empty string as the value and
without a value at all. However, by specifying a blank value I have complied
with the RFC. The value attribute there.

Also I disagree that a blank string in terms of post submission is not a
non-existant value. Reading the headers of the POST, it is clear that the
value is passed through, and that the value is an empty string. This is the
difference between a Database NULL value and an empty string.

I maintain that this is a bug, and that ASP.Net should distinguish between
when the value hasn't been set (eg <input name="RadioButtons" id="Button2"
type="radio" />) and when the value has been set to an empty string (eg
<input value="" name="RadioButtons" id="Button2" type="radio" />).

"Kevin Spencer" wrote:
Hi David,

It is not a bug. According to http://www.ietf.org/rfc/rfc1866.txt, the
"value" attribute of an HTML radio button is required. That is, it cannot be
blank, or non-existent. This is also true of a checkbox. The reason for the
radio button's value being required is that a radio button group has a
single value, and that value is the value of the radio button in the group
that is checked. A blank string, in terms of a form POST submission, is a
non-existent value. Therefore, your value must be at least 1 character in
size. ASP.Net knows about this, and corrects it by assigning the radio
button's unique ID to the value property.

Nov 19 '05 #3

P: n/a
> After reading the RFC, it specifies that for a radio button and a checkbox
both the value and the name are required ("The NAME and VALUE attributes
are
required as for check boxes"). Interestingly using the W3C online
validator,
this code passes validation both with an empty string as the value and
without a value at all. However, by specifying a blank value I have
complied
with the RFC. The value attribute there.
Microsoft does not make decisions regarding their object models based on
what passes in a W3C validator program. They make their decisions based upon
the RFCs, which are the ultimate authority. This is logical. The Oxford
Englidh dictionary is the ultimate authority regarding the spelling of any
word in the English language. If Oxford were to put out a spell-checker
application that happened to allow for incorrect spellings, due to the
latency between the revision of the Dictionary and the revision of the
spell-checker, the Dictionary would still be the authority. Or, as another
example, the codified laws of the US are the ultimate authority regarding
what is law. The judges that arbitrate cases are not. This is why we have
courts of appeals. Judges make mistakes.
Also I disagree that a blank string in terms of post submission is not a
non-existant value. Reading the headers of the POST, it is clear that the
value is passed through, and that the value is an empty string. This is
the
difference between a Database NULL value and an empty string.
A blank string in an HTTP POST is a non-existent value, as EVERYTHING in an
HTTP POST is a string. IOW, there is no distinction when referring to all
string content between NULL and an empty string. The fact that the name is
passed is irrelevant regarding this issue. In a database, or a programming
platform, there are many different data types, and NULL is not a string.
This is only possible because there are many different data types.
I maintain that this is a bug, and that ASP.Net should distinguish between
when the value hasn't been set (eg <input name="RadioButtons" id="Button2"
type="radio" />) and when the value has been set to an empty string (eg
<input value="" name="RadioButtons" id="Button2" type="radio" />).
As I have pointed out, for the 2 reasons specified and explained above, you
may maintain your opinion until the cows come home, but Microsoft will not
change the object model to suit an opinion. Microsoft is all about standards
these days. They will conform to the standard. Of course, writing a custom
radio button Server Control is a piece of cake, and you are free to "roll
your own" for your own use.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"David Cameron" <Da**********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com... Thanks for the reply.

After reading the RFC, it specifies that for a radio button and a checkbox
both the value and the name are required ("The NAME and VALUE attributes
are
required as for check boxes"). Interestingly using the W3C online
validator,
this code passes validation both with an empty string as the value and
without a value at all. However, by specifying a blank value I have
complied
with the RFC. The value attribute there.

Also I disagree that a blank string in terms of post submission is not a
non-existant value. Reading the headers of the POST, it is clear that the
value is passed through, and that the value is an empty string. This is
the
difference between a Database NULL value and an empty string.

I maintain that this is a bug, and that ASP.Net should distinguish between
when the value hasn't been set (eg <input name="RadioButtons" id="Button2"
type="radio" />) and when the value has been set to an empty string (eg
<input value="" name="RadioButtons" id="Button2" type="radio" />).

"Kevin Spencer" wrote:
Hi David,

It is not a bug. According to http://www.ietf.org/rfc/rfc1866.txt, the
"value" attribute of an HTML radio button is required. That is, it cannot
be
blank, or non-existent. This is also true of a checkbox. The reason for
the
radio button's value being required is that a radio button group has a
single value, and that value is the value of the radio button in the
group
that is checked. A blank string, in terms of a form POST submission, is a
non-existent value. Therefore, your value must be at least 1 character in
size. ASP.Net knows about this, and corrects it by assigning the radio
button's unique ID to the value property.

Nov 19 '05 #4

P: n/a
Hi David,

To be completely truthful, some of my original reply was conjecture. That
is, the explanation that the RFC requires a value for a radio button was
fact. My explanation of why the RFC requires this was conjecture. So, I
could be wrong about the "why" of it.

In either case, Microsoft is not going to consider their model for the
RadioButtonControl a bug, and your best bet, if you want to use a blank
value in a radio button control is to create your own.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"David Cameron" <Da**********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Thanks for the reply.

After reading the RFC, it specifies that for a radio button and a checkbox
both the value and the name are required ("The NAME and VALUE attributes
are
required as for check boxes"). Interestingly using the W3C online
validator,
this code passes validation both with an empty string as the value and
without a value at all. However, by specifying a blank value I have
complied
with the RFC. The value attribute there.

Also I disagree that a blank string in terms of post submission is not a
non-existant value. Reading the headers of the POST, it is clear that the
value is passed through, and that the value is an empty string. This is
the
difference between a Database NULL value and an empty string.

I maintain that this is a bug, and that ASP.Net should distinguish between
when the value hasn't been set (eg <input name="RadioButtons" id="Button2"
type="radio" />) and when the value has been set to an empty string (eg
<input value="" name="RadioButtons" id="Button2" type="radio" />).

"Kevin Spencer" wrote:
Hi David,

It is not a bug. According to http://www.ietf.org/rfc/rfc1866.txt, the
"value" attribute of an HTML radio button is required. That is, it cannot
be
blank, or non-existent. This is also true of a checkbox. The reason for
the
radio button's value being required is that a radio button group has a
single value, and that value is the value of the radio button in the
group
that is checked. A blank string, in terms of a form POST submission, is a
non-existent value. Therefore, your value must be at least 1 character in
size. ASP.Net knows about this, and corrects it by assigning the radio
button's unique ID to the value property.

Nov 19 '05 #5

P: n/a
Thanks for taking the time to answer.
Microsoft does not make decisions regarding their object models based on
what passes in a W3C validator program. They make their decisions based upon
the RFCs, which are the ultimate authority. This is logical. The Oxford
Englidh dictionary is the ultimate authority regarding the spelling of any
word in the English language. If Oxford were to put out a spell-checker
application that happened to allow for incorrect spellings, due to the
latency between the revision of the Dictionary and the revision of the
spell-checker, the Dictionary would still be the authority. Or, as another
example, the codified laws of the US are the ultimate authority regarding
what is law. The judges that arbitrate cases are not. This is why we have
courts of appeals. Judges make mistakes.
Don't give me that. W3C is the authorative source for HTML and CSS. That RFC
you have linked to is for HTML 2.0. If you read the blurb for the RFC it
states it is "Obsoleted by RFC2854". If you then read that RFC
(ftp://ftp.rfc-editor.org/in-notes/rfc2854.txt) it states in the abstract:
"This document was prepared at the request of the W3C HTML working
group. Please send comments to ww******@w3.org, a public mailing list
with archive at <http://lists.w3.org/Archives/Public/www-html/>"
and later in the introduction:
"The IETF HTML working group closed Sep 1996, and work on defining
HTML moved to the World Wide Web Consortium (W3C). The proposed
extensions were incorporated to some extent in [HTML32], and to a
larger extent in [HTML40]."

So W3C is the ultimate authority when it comes to HTML. Microsoft *should*
be making their decisions based on what passes the W3C validator.
A blank string in an HTTP POST is a non-existent value, as EVERYTHING in an
HTTP POST is a string. IOW, there is no distinction when referring to all
string content between NULL and an empty string. The fact that the name is
passed is irrelevant regarding this issue. In a database, or a programming
platform, there are many different data types, and NULL is not a string.
This is only possible because there are many different data types.
I don't think that the fact that the name is passed is irrelevant. I still
get a POSTed blank string. I have yet to see anything that suggests this is
non-standard behaviour. When running server side for ASP.net, PHP and asp
(the languages I have used in web development), there is a distinction in
POSTed data between an input whote value is an empty string and an input that
doesn't exist.
As I have pointed out, for the 2 reasons specified and explained above, you
may maintain your opinion until the cows come home, but Microsoft will not
change the object model to suit an opinion. Microsoft is all about standards
these days. They will conform to the standard. Of course, writing a custom
radio button Server Control is a piece of cake, and you are free to "roll
your own" for your own use.


Microsoft is about standards. Well that is a change. The IE team only agreed
to implement the CSS 2.* spec after significant pressure from the development
community (just read the comments on IE blog *before* they announced they
would support CSS 2.1). We could be generous and assume that they were going
to do it anyway, however nothing in any of the public statements regarding
IE's features suggested that they might. As for following standards, I submit
the following:
http://validator.w3.org/check?uri=http%3A%2F%2Fmsdn.microsoft.com%2Fnewsgr oups%2Fdefault.aspx%3Fdg%3Dmicrosoft.public.dotnet .framework.aspnet%26mid%3D06e47415-8e7b-494f-8fa4-6839754ca9d0

Hoevere this is neither here nor there. As I understand the standard you
have posted, a blank string is a valid value. As you have stated in your
other comment, it is conjecture that a blank string in an invalid value.

Of couse there is an immediate fix, for this, as you suggested I can roll my
own. But I state again, I regard this as a bug in ASP.Net that seems to be
based a misreading of the standards.

If it isn't clear, I am also annoyed because I feel I am being given the run
around.
Nov 19 '05 #6

P: n/a
If the standard has changed, or if the Microsoft understanding of the
standard is incorrect, look for a change in the next (or following) version
of the CLR. From what I've learned, Microsoft is concentrating more on XHTML
than on existing implementations of HTML. This is a good thing, as HTML will
ultimately be replaced with XHTML. In the meantime, however, as difficult as
it is to keep up, I do believe Microsoft is doing their best to do so.
Remember that the .Net platform 1.1 is several years old, and took several
years to build.
Microsoft is about standards. Well that is a change. The IE team only
agreed
to implement the CSS 2.* spec after significant pressure from the
development
community (just read the comments on IE blog *before* they announced they
It is a change, but it has been occurring over a number of years with
increasing speed. It started sometime around the year 1998 - 2000. I have
personally observed quite a bit of movement in quite a number of products
and technologies over the past 5 years.

I can't argue with you about IE. IE has fallen behind quite a bit, but
almost entirely due to its critical role in the Windows operating system.
This prevents IE from being rolled out as quickly and regularly as competing
browsers, and makes modifying it complex and difficult. In addition, it is
important to remember that Microsoft makes a huge amount of software, and
much of it interoperates with other Microsoft software. Microsoft employs
over 50,000 people, and making changes in their products doesn't happen "on
a dime."

The Microsoft web site is one of the worst examples of the slowness of this
progress. Even as a fan of Microsoft, I generally prefer to use FireFox, but
whenever I go to the Microsoft site, I use IE because of the poor support
for non-IE browsers there. On the other hand, it is possibly the single
largest web site in the world, and will take time to adapt. I expect it
will.

I have been one of the most ardent advocates with Microsoft, in my
interactions with them, for the adoption and support of external CSS style
sheets, for about 4 years now. I have seen this in ASP.Net 2.0, and
not-yet-released versions of other products which I am not at liberty to
discuss. Have I been frustrated by the speed with which they have done this?
Very.

Still, Microsoft has openly committed to following standards, and I expect
them to continue to do so. Transact-SQL, the SQL flavor used by Microsoft
SQL Server, more closely conforms to ISO SQL than any other flavor that I've
seen, although MySQL is pretty close. The .Net platform 2.0 certainly has
made quite a number of standards-based changes, all of which I'm sure we
will all welcome. The next version of IE (IE 7) is now available as a beta 1
download, and although it behaves much like any other beta 1 software (in
other words, don't install it on a production machine!), it shows a lot of
promise.

In the meantime, it would take you about 30 minutes to write your own radio
button Control, and my guess is, it would be an eye-opening experience for
you. The built-in ASP.Net Controls were never intended by Microsoft to be
the only Server Controls used by developers. There is an entire section in
the .Net SDK on how to develop your own. See:

http://msdn.microsoft.com/library/en...asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"David Cameron" <Da**********@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com... Thanks for taking the time to answer.
Microsoft does not make decisions regarding their object models based on
what passes in a W3C validator program. They make their decisions based
upon
the RFCs, which are the ultimate authority. This is logical. The Oxford
Englidh dictionary is the ultimate authority regarding the spelling of
any
word in the English language. If Oxford were to put out a spell-checker
application that happened to allow for incorrect spellings, due to the
latency between the revision of the Dictionary and the revision of the
spell-checker, the Dictionary would still be the authority. Or, as
another
example, the codified laws of the US are the ultimate authority regarding
what is law. The judges that arbitrate cases are not. This is why we have
courts of appeals. Judges make mistakes.


Don't give me that. W3C is the authorative source for HTML and CSS. That
RFC
you have linked to is for HTML 2.0. If you read the blurb for the RFC it
states it is "Obsoleted by RFC2854". If you then read that RFC
(ftp://ftp.rfc-editor.org/in-notes/rfc2854.txt) it states in the abstract:
"This document was prepared at the request of the W3C HTML working
group. Please send comments to ww******@w3.org, a public mailing list
with archive at <http://lists.w3.org/Archives/Public/www-html/>"
and later in the introduction:
"The IETF HTML working group closed Sep 1996, and work on defining
HTML moved to the World Wide Web Consortium (W3C). The proposed
extensions were incorporated to some extent in [HTML32], and to a
larger extent in [HTML40]."

So W3C is the ultimate authority when it comes to HTML. Microsoft *should*
be making their decisions based on what passes the W3C validator.
A blank string in an HTTP POST is a non-existent value, as EVERYTHING in
an
HTTP POST is a string. IOW, there is no distinction when referring to all
string content between NULL and an empty string. The fact that the name
is
passed is irrelevant regarding this issue. In a database, or a
programming
platform, there are many different data types, and NULL is not a string.
This is only possible because there are many different data types.


I don't think that the fact that the name is passed is irrelevant. I still
get a POSTed blank string. I have yet to see anything that suggests this
is
non-standard behaviour. When running server side for ASP.net, PHP and asp
(the languages I have used in web development), there is a distinction in
POSTed data between an input whote value is an empty string and an input
that
doesn't exist.
As I have pointed out, for the 2 reasons specified and explained above,
you
may maintain your opinion until the cows come home, but Microsoft will
not
change the object model to suit an opinion. Microsoft is all about
standards
these days. They will conform to the standard. Of course, writing a
custom
radio button Server Control is a piece of cake, and you are free to "roll
your own" for your own use.


Microsoft is about standards. Well that is a change. The IE team only
agreed
to implement the CSS 2.* spec after significant pressure from the
development
community (just read the comments on IE blog *before* they announced they
would support CSS 2.1). We could be generous and assume that they were
going
to do it anyway, however nothing in any of the public statements regarding
IE's features suggested that they might. As for following standards, I
submit
the following:
http://validator.w3.org/check?uri=http%3A%2F%2Fmsdn.microsoft.com%2Fnewsgr oups%2Fdefault.aspx%3Fdg%3Dmicrosoft.public.dotnet .framework.aspnet%26mid%3D06e47415-8e7b-494f-8fa4-6839754ca9d0

Hoevere this is neither here nor there. As I understand the standard you
have posted, a blank string is a valid value. As you have stated in your
other comment, it is conjecture that a blank string in an invalid value.

Of couse there is an immediate fix, for this, as you suggested I can roll
my
own. But I state again, I regard this as a bug in ASP.Net that seems to be
based a misreading of the standards.

If it isn't clear, I am also annoyed because I feel I am being given the
run
around.

Nov 19 '05 #7

P: n/a
Thanks again for the honest reply. I do appreciate the time you have spent on
this.

What you say is entirely correct, and I understand that it can take some
timefor Microsoft to make changes, given the age of ASP.Net, and of couse the
possibility that it may break existing applications.

Yes, Microsoft has also produced some products that do really follow the
standards. You've named T-SQL. They have also consistently produced one of
the most (if not the most) standards compliant C++ compilers.

That aside, I've written a few controls, mostly specific to the application
I am working on.
Nov 19 '05 #8

P: n/a
> That aside, I've written a few controls, mostly specific to the
application
I am working on.
I've written a few myself! Actually, I rather enjoy doing it. It's a
challenge to design something for reusability. And I must admit, I'm more of
a back-end guy myself. Still, writing reusable interface classes is just as
much fun in a different way as writing business classes.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"David Cameron" <Da**********@discussions.microsoft.com> wrote in message
news:4A**********************************@microsof t.com... Thanks again for the honest reply. I do appreciate the time you have spent
on
this.

What you say is entirely correct, and I understand that it can take some
timefor Microsoft to make changes, given the age of ASP.Net, and of couse
the
possibility that it may break existing applications.

Yes, Microsoft has also produced some products that do really follow the
standards. You've named T-SQL. They have also consistently produced one of
the most (if not the most) standards compliant C++ compilers.

That aside, I've written a few controls, mostly specific to the
application
I am working on.

Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.